Using module controllers in application controllers

For example, i have module with controller modulController:


/protected/modules/mymodule/controllers/ModuleController.php

And application controller:


/protected/controllers/MyController.php

How i can call methods of ModuleController class in MyController class?

You cannot cross-call actions, specify your business logic in your models, so you can keep your controllers neat and straight-forward.

For example:




http://myapp?r=admin&request=/pages/admin/add

[code]


[code]

class AdminController extends CController {

  public function actionIndex() {

    //parse request e.t.c

    ...

    if(Yii::app()->modules->isInstalled($request)) { //modules component. add/remove/list modules in system

      ...//call adminController of pages module for render admin page for this module

    }

  }

}



So We have modules "pages", "forum" e.t.c and we have managing/exec logic in AdminController for this modules. This logic can render admin modules controllers, add modul/delete modul/update module user interface e.t.c

Another way maybe: module/submodules. Sub module can access for methods of parent module, using layout of parent module e.t.c?

It simply doesn’t make sense to use one controllers methods in another.

If you have a method that’s required in two controllers then create a component (i.e. a decorated Yii Class) and use that. Maybe use it as a behavior, which is probably easiest.