createAction() публичный Метод

The method first checks if the action ID has been declared in Controller::actions. If so, it will use the configuration declared there to create the action object. If not, it will look for a controller method whose name is in the format of actionXyz where Xyz stands for the action ID. If found, an InlineAction representing that method will be created and returned.
public createAction ( string $id ) : Action
$id string the action ID.
Результат Action the newly created action instance. Null if the ID doesn't resolve into any action.
Пример #1
0
 /**
  * @param \yii\base\Controller $controller
  * @return array
  */
 protected function getActions(\yii\base\Controller $controller)
 {
     $actions = [];
     // inline actions
     $reflection = new \ReflectionObject($controller);
     $methods = $reflection->getMethods(\ReflectionMethod::IS_PUBLIC);
     $methods = array_filter($methods, function ($method) {
         return strpos($method->name, 'action') === 0 && $method->name != 'actions';
     });
     foreach ($methods as $method) {
         $actionId = strtolower(preg_replace('/([A-Z]){1}/', '-$1', lcfirst(substr($method->name, 6))));
         $dockBlock = null;
         try {
             $dockBlock = new DocBlockReflection($method);
         } catch (\Exception $e) {
         }
         $action = new ActionAdapter($controller->createAction($actionId), $dockBlock);
         $actions[$actionId] = $action;
     }
     // external actions
     foreach ($controller->actions() as $actionId => $alias) {
         $actions[$actionId] = new ActionAdapter($controller->createAction($actionId));
     }
     return $actions;
 }