createController() public method
Creates a controller instance based on the given route.
The route should be relative to this module. The method implements the following algorithm to resolve the given route:
- If the route is empty, use $defaultRoute;
- If the first segment of the route is a valid module ID as declared in $modules, call the module's
createController()
with the rest part of the route; - If the first segment of the route is found in $controllerMap, create a controller based on the corresponding configuration found in $controllerMap;
- The given route is in the format of
abc/def/xyz
. Try eitherabc\DefController
orabc\def\XyzController
class within the controller namespace.
If any of the above steps resolves into a controller, it is returned together with the rest part of the route which will be treated as the action ID. Otherwise, false
will be returned.
public array|boolean createController ( $route ) | ||
---|---|---|
$route | string |
The route consisting of module, controller and action IDs. |
return | array|boolean |
If the controller is created successfully, it will be returned together with the requested action ID. Otherwise |
throws | yii\base\InvalidConfigException |
if the controller class and its file do not match. |
Please login to continue.