本文整理汇总了PHP中yii\base\Controller::createAction方法的典型用法代码示例。如果您正苦于以下问题:PHP Controller::createAction方法的具体用法?PHP Controller::createAction怎么用?PHP Controller::createAction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\base\Controller
的用法示例。
在下文中一共展示了Controller::createAction方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getActions
/**
* @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;
}