I have model and entity in my CakePHP(latest) app that I want to extend in this way. I want to tell the cake to use ExtraStuff model class instead of app Stuff
App\Model\Table\Stuff
MyPlugin\Model\Table\ExtraStuff
I'm trying to redefine model in the main controller in beforeRender method with methods from Cake\Datasource\ModelAwareTrait
/**
* Override a existing callable to generate repositories of a given type.
*
* @param string $type The name of the repository type the factory function is for.
* @param callable $factory The factory function used to create instances.
* @return void
*/
modelFactory($type, callable $factory)
Or how I can do it? I have a lot of $this->loadModel('Stuff') calls inside the project and I need to tell the app use ExtraStuff class when I need. Thanks.