base\Module createController()

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:

  1. If the route is empty, use $defaultRoute;
  2. 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;
  3. If the first segment of the route is found in $controllerMap, create a controller based on the corresponding configuration found in $controllerMap;
  4. The given route is in the format of abc/def/xyz. Try either abc\DefController or abc\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 false will be returned.

throws yii\base\InvalidConfigException

if the controller class and its file do not match.

doc_Yii
2016-10-30 16:52:03
Comments
Leave a Comment

Please login to continue.