Hi everyone,
i really like the concept of modules in yii. You create your generic part of an Application once, and re-use it as a
pluggable Module everywhere you want.
Unfortunately i have encountered a problem. I think this is a design flaw in the module System of yii:
It’s my Goal to have two different modules, the well-knows SRBAC for the Administration of user privilegies, and
a Module called ‘user’ that handles User Authentication, Messaging between users, User Profile Management, Password
recovery and so on.
I have one Table called ‘users’ containing all users. This table is shared by both modules. That means:
The model::User() of module srbac as well as the model::User() of module user have the same tableName() .
This is no problem so far, but now it gets interesting:
To make both modules as reusable as possible, both modules define their ‘userClass’-Name in the Module Configuration.
This looks like this:
'modules' => array(
'user' => array(
'userClass' => 'Users'),
'srbac' => array(
'userClass' => 'Users'),
When running actions under srbac/ everything works fine, as well when running actions under user/ standalone.
But now i want to make it possible, for example, to call a method of the User::model() that’s located in the other module.
Unfortunately this won’t work because the Yii::app()->controller->module is always set to the module thats actual running.
Yii will include modules/module1/models/model.php instead of the modules/module2/models/model.php that contains my wanted Method.
What needs to be made possible is a switch/toggle made available at runtime so one can decide which Module should be accessed
under the actual context in the action executed.
btw: the same problem occurs when i try to access a module Model from outside of the Model.
Maybe i have understood something wrong and there is an easy solution to this situation? What do you think?