Hi Guys,
To me it seems this should be a common task, but maybe I’m just too dumb,
have not enough skills or my brain is malfunctioning at the moment…
I just can’t figure this out.
Lets say you write a module.
In this module you need specific stuff inside the User Model,
which is only used by this module.
So you want to extend a Model from main application to keep all module-specific stuff "inside" your module.
Currently I’m doing it like this:
namespace myModule\models;
use path\to\main\application\User as AppUser;
class User extends AppUser
{
/**
* Extend this class to module specific queries & functions
*/
}
This works - but the problem is:
If somebody else wants to use your module,
he has to "dig inside" your code and has to change the path according to his app-configuration.
Which is not good, since he always has to change this again when there is an update.
(You could compare the issue with changing code in "vendor" and there is an update of the composer package - it would overwrite all changes)
So it would be nice, if there is a way to do something like this:
'custom-module' => [
'class' => 'mynamespace\path\to\Module',
'userClass' => 'app\models\User'
],
And inside the module extend from given "userClass".
I hope the issue is clear described.
If not - let me know.
Every help / hint regarding this issue is very welcome.
Best Regards