I wonder if there is a method to register a listener on a Behavior so that when it is removed from a Table it can perform some action.
I have a Behavior that creates table associations when it’s added to a table. I would like to register a listener on that behavior so that removing the behavior from table the associations are removed too. I would put all the logic in the Behavior to decouple it from Table.
I didn’t found any event triggered on removing behaviors.
I’m not sure but maybe you can do this by overriding http://api.cakephp.org/3.2/source-class-Cake.ORM.Table.html#2215 and adding removeBehavior here?
Mmmm… I don’t think so. That method maps events to some listener, but then I miss the trigger.
I could do it overriding
Table::removeBehavior() http://api.cakephp.org/3.2/source-class-Cake.ORM.Table.html#622 and trigger an event (for example
Model.removeBehavior) on which hook my listener.
But I hoped to not involve modifing on Table classes.