Example #1
0
 /**
  * Returns all available actions of the specified controller.
  * Taken from Yii2 HelpController.
  *
  * @param Controller $controller the controller instance
  *
  * @return array all available action IDs.
  */
 public static function getControllerActions($controller)
 {
     if (!$controller) {
         return [];
     }
     $actions = [];
     $prefix = $controller->module->id === Yii::$app->id ? '/' . $controller->id . '/' : $controller->module->id . '/' . $controller->id . '/';
     foreach ($controller->actions() as $name => $importedActions) {
         $actions[] = ['name' => $name, 'route' => Yii::$app->urlManager->createUrl($prefix . $name)];
     }
     $class = new \ReflectionClass($controller);
     foreach ($class->getMethods() as $method) {
         $name = $method->getName();
         if ($method->isPublic() && !$method->isStatic() && strpos($name, 'action') === 0 && $name !== 'actions') {
             $action = Inflector::camel2id(substr($name, 6), '-', true);
             $actions[] = ['name' => $action, 'route' => Yii::$app->urlManager->createUrl($prefix . $action)];
         }
     }
     //sort($actions);
     return $actions;
     #return array_unique($actions);
 }
Example #2
0
 /**
  * Declares class-based actions.
  */
 public function actions()
 {
     return array_merge(parent::actions(), array('captcha' => array('class' => 'CCaptchaAction', 'foreColor' => 0x6091ba, 'backColor' => 0xffffff, 'testLimit' => 1), 'page' => array('class' => 'CViewAction')));
 }
Example #3
0
 public function actions()
 {
     return CMap::mergeArray(parent::actions(), array('login' => 'LoginAction', 'logout' => 'LogoutAction'));
 }
 public function actions()
 {
     $actionMaps = parent::actions();
     $actionMaps['logout'] = 'common.actions.LogoutAction';
     return $actionMaps;
 }