cakephp / elastic-search

Elastic search datasource for CakePHP
Other
88 stars 53 forks source link

Could we implement addBehavior()? #83

Closed damianoporta closed 4 years ago

damianoporta commented 8 years ago

Hello, it seems that we cannot attach behavior to a type, is this an issue or does it has not been implemented yet?

damianoporta commented 8 years ago

if we can not use behaviors now, is there any workaround?

markstory commented 8 years ago

Behaviors are a bit tricky. While we could add them, I have concerns that many core and userland behaviors don't make sense in elastic search. For example TreeBehavior, TranslateBehavior make no sense and really have no way of properly functioning.

damianoporta commented 8 years ago

@markstory you are right, but in this case there are other plugins like file-upload that need before/after save logic. With no behaviors we must create custom listeners somewhere and add callbacks for Model.before/afterSave

I tried to see how behaviorRegistry works, it accepts a Table object on its constructor, if we will implement behaviors...should we modify it or create another one "registry" ?

Thanks!

damianoporta commented 8 years ago

@markstory for example the FriendsOfCake/Search plugin too.

lorenzo commented 8 years ago

I don't think it is a good idea. At least using "behaviors" as a word is not a good idea. We could perhaps duplicate the concept with a different name.

github-actions[bot] commented 4 years ago

This issue is stale because it has been open for 120 days with no activity. Remove the stale label or comment or this will be closed in 15 days

PhantomWatson commented 4 years ago

My current use case that seems to call for a behavior is that I have a SQL table and an Elasticsearch index that represent data with the same fields, and I'd like to have them share custom finder methods. I don't think that this can be accomplished well with traits or class inheritance.