Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No callbacks are called #84

Closed
dario86 opened this issue Feb 8, 2016 · 7 comments
Closed

No callbacks are called #84

dario86 opened this issue Feb 8, 2016 · 7 comments
Assignees
Labels
Milestone

Comments

@dario86
Copy link

dario86 commented Feb 8, 2016

Hi, I have this code in my controller:

public function formStupido()
{
        $Companies = TypeRegistry::get('Companies.Companies');
        $companies = $Companies->newEntity(['name' => 'ciao']);
        $savedCompany = $Companies->save($companies);
}

This is my CompaniesType in plugin Companies:

<?php
namespace Companies\Model\Type;

use Cake\ElasticSearch\Type;
use Cake\ElasticSearch\Query;
use Cake\ElasticSearch\FilterBuilder;
use App\Lib\FileUpload;

class CompaniesType extends Type
{
    /**
     * initialize method
     * 
     * @param array $config
     */
    public function initialize(array $config)
    {

    }

    public function beforeMarshal(Event $event, ArrayObject $data, ArrayObject $options)
    {
        debug('marshaller');
        exit();
    }

    public function beforeSave(Event $event, ArrayObject $data, ArrayObject $options)
    {
        debug('before');
        exit();
    }
}
?>

Document is created and no callbacks are called

@damianoporta
Copy link
Contributor

same here!

@josegonzalez
Copy link
Member

@markstory I know you're not a fan of adding behavior support because some behaviors may be incompatible, but couldn't the same thing be said about a behavior targeting a specific database? For instance, I could write something that targeted a specific column type only available to postgres. I don't see why we can't put a big fat caveat on this plugin and say certain core behaviors are not expected to work (or make them work).

@markstory markstory added this to the 1.0.0 milestone Feb 9, 2016
@markstory
Copy link
Member

I don't see why we can't put a big fat caveat on this plugin and say certain core behaviors are not expected to work (or make them work).

Outside of the TimestampBehavior, I'm not sure any of the core behaviors work.

@markstory markstory added the bug label Feb 9, 2016
@markstory markstory self-assigned this Feb 9, 2016
@markstory
Copy link
Member

Looks like we never implemented the default callback binding, for Type. I'll add that in.

@josegonzalez
Copy link
Member

@markstory how difficult would it be to test that? Why do you think they wouldn't work?

markstory added a commit that referenced this issue Feb 9, 2016
This lets the elasticsearch plugin work more like the ORM.

Refs #84
@markstory
Copy link
Member

Pull request up now.

@markstory
Copy link
Member

@josegonzalez I don't think the others would work based on how they are implemented. TreeBehavior, CounterCache and TranslateBehavior rely on association methods that do not exist in elasticsearch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants