Пример #1
0
 public function createAction($actionID)
 {
     $action = parent::createAction($actionID);
     if ($action !== null) {
         return $action;
     }
     foreach ($this->_behaviorIDs as $behaviorID) {
         $object = $this->asa($behaviorID);
         if ($object->getEnabled() && method_exists($object, 'action' . $actionID)) {
             return new CInlineAction($object, $actionID);
         }
     }
 }
Пример #2
0
 /**
  * This overrides the default behaviour for supported resources by pushing the resource
  * into the GET parameter and updating the actionID.
  *
  * This is necessary because there's no way of pushing the appropriate pattern to the top of the
  * URLManager config, so this captures calls where the id doesn't contain non-numerics.
  *
  * @param string $actionID
  *
  * @return \CAction|\CInlineAction
  */
 public function createAction($actionID)
 {
     if (in_array($actionID, static::$resources)) {
         $_GET['resource_type'] = $actionID;
         switch (\Yii::app()->getRequest()->getRequestType()) {
             case 'PUT':
                 return parent::createAction('Update');
                 break;
             case 'DELETE':
                 return parent::createAction('Delete');
                 break;
             default:
                 $this->sendResponse(405);
                 break;
         }
     }
     return parent::createAction($actionID);
 }
Пример #3
0
 /**
  * Creates the action instances for the given controller
  * @param \CController $controller the controller to get actions for
  *
  * @return \CAction[] the controller actions
  */
 protected function createActionInstances(\CController $controller)
 {
     $actions = array();
     foreach ($controller->actions() as $id => $config) {
         $actions[$id] = $controller->createAction($id);
     }
     $reflector = new \ReflectionObject($controller);
     foreach ($reflector->getMethods() as $name => $method) {
         if ($name != 'actions' && substr($name, 0, 6) == 'action') {
             $id = lcfirst(substr($name, 6));
             $actions[$id] = $controller->createAction($id);
         }
     }
     return $actions;
 }
Пример #4
0
 /**
  * Creates the action instance based on the action name.
  * Additionally, this implementing checks attached behaviors for actions.
  */
 public function createAction($actionID)
 {
     $action = parent::createAction($actionID);
     // search in behaviors
     if ($action === null) {
         foreach ($this->behaviors() as $behavior => $data) {
             $behavior = $this->{$behavior};
             if (is_subclass_of($behavior, 'IBehavior') && method_exists($behavior, 'action' . $actionID)) {
                 return new CInlineAction($behavior, $actionID);
             }
         }
     }
     return $action;
 }