Hi, my application has several ends:
-
"front" end
-
"robot" end
-
"panel/manager" end
-
"panel/centr" end
-
"panel/provider" end
the implementation of several ends in one application is like this one http://www.yiiframework.com/wiki/63/
But, it has one problem. Controller class names in each end can be the same.
For example, I can open protected/controller/front/TaskController (which extends BaseTaskController, which extends Controller, which extends CController) from front-end and do something from front-end.
And I can also open another protected/controller/panel/manager/TaskController from manager panel, and do something.
Classes with same names in one project is very bad.
I want end-controllers to have different names, like "TaskFrontController", "TaskManagerController".
I tried to do this in different ways, including changing urlManager rules.
Finaly i came up with idea that the only good implementation, is to change strings of CWebApplication->createController
from
$className=ucfirst($id).'Controller';
$classFile=$basePath.DIRECTORY_SEPARATOR.$className.'.php';
to
$className=$this->getControllerClassName($id);
$classFile=$basePath.DIRECTORY_SEPARATOR.$className.'.php';
where getControllerClassName is
/*
* Controller name by id, => IdEndnameController
*/
public function getControllerClassName($id){
return(ucfirst($id).$this->_endControllerPostfix.'Controller');
}
but i can’t find the way to do it, without creating new core class “CWebEndApplication”, extending CWebApplication and overriding createController method.
Is it the only way to do that?