In modules actions declared in actions() method of controller, controllers which I call in modules have the same name, and action which I call have the same name too. But in result I get the output the same for each module - from first module. I’ve changed the names of actions in modules, and now it works fine, but I need the same names for my actions - to provide some kind of common interface for modules interoperation.
I’m having similar problem when using Yii::app()->runController(‘module/controller/action’) to call a number of module controller/actions in a loop. The modules have common controller/action names. The purpose is to get portlets on a page to be rendered by the respective modules. It seems that runController() will always call the the controller/actions for the first module in the loop eventhough the route specified are for subsequent modules. Below is my sample code:
That approach is completely wrong, don’d do like that.
Never use Yii::app()->createController($module->id.’/’.‘admin’), it is not necessary.
If you need to share some code, share in a model if it has a meaning, otherways in a compoment.
Create a component (a class in component) and copy here the code you want to share as a static method, then call MYcompoment::myfunction() in both places.
Business logic should NOT reside in controllers, therefore there is no need to call a function of some controller in some other controller.