Reputation: 6106
I would like to implement an autoslug-function for two models in CakePHP3 and use the beforeSave
-callback for that which works fine. However the slug structure is a bit different than in Inflector::slug
, so I wrote a small function for the different structure which finally leads to my question
In Cake2 I would have placed this helper function in AppModel which is not existing anymore. What's the best way to do that now? A behaviour (which seems a bit biggish for 2 lines of code) or class AppTable extends Table
or ..?
Upvotes: 2
Views: 2036
Reputation: 25698
Make it a behavior and use it where needed instead of putting it in a super model class. If you put that into a plugin and repository you can simply add your plugin as package via composer for every app that needs this plugin.
Upvotes: 5