开发者

Yii accessing a nested module

开发者 https://www.devze.com 2023-03-28 21:56 出处:网络
I have an admin module which I\'m using for backend user management etc... I would like to have the \'rights\' extension nested under this admin module and be able to get to it with mysite.com/index.

I have an admin module which I'm using for backend user management etc...

I would like to have the 'rights' extension nested under this admin module and be able to get to it with mysite.com/index.php?r=admin/rights

Apparently I need to declare child modules in the parent so under the AdminModule init, i've set:

$this->setModules(array(
    'rights'=>array(
        'install'=>true, // rights - Enables the installer
        'baseUrl'=>'/admin/rights',
        'debug'=>true,
    ),
));

I've also tried importing from AdminModule init: (clueless on this one)

$this->setImport(array(
    'admin.models.*',
    'admin.components.*',
    'admin.modules.rights.*',
    'admin.modules.rights.components.*',
));

Also I've tried declaring the module in the main.php config:

'admin'=>array(
    'modules'=>array(
        'rights'=>array(
            'install'=>true, // rights - Enables the installer
            'baseUrl'=>'/admin/rights',
            'debug'=>true,
         ),
     ),
),

And even importing it there:

'import'=>array(
    'application.models.*',
    'application.components.*',
    'application.modules.admin.*',
    'application.modules.admin.modules.ri开发者_StackOverflow中文版ghts.*', // rights
    'application.modules.admin.modules.rights.components.*', // rights
),

Anywho, no matter what I've tried so far, I cannot get to the rights module. It gives me Unable to resolve the request "admin/rights". when trying to get to admin/rights.

The extension works fine as an un-nested module at ?r=rights. Any ideas? I've not found many examples of the actual code when dealing with nested modules.


Could the problem be a missing route?

Try adding the following:

<module:\w+>/<controller:\w+>/<action:\w+>'=>'<module>/<controller>/<action>


I guess that you have multiple rights modules. To use particular one (from „deeper“ hierarchy) you must declare its class. Something like that:

'admin'=>array(
    'modules'=>array(
        'rights'=>array(
            'class' => 'application.modules.admin.modules.rights.RightsModule'
         ),
     ),
),
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号