For more details and usage information on OptionsAction, see the guide article on rest controllers.
Since: 2.0
Author: Qiang Xue (qiang.xue@gmail.com)
Inheritance: extends yii\base\Action
Example #1
0
 /**
  * Responds to the OPTIONS request.
  *
  * @param $id
  */
 public function actionOptions($id = null)
 {
     $action = new OptionsAction($this->action->id, $this->id);
     $action->resourceOptions = ['GET', 'DELETE', 'HEAD', 'OPTIONS'];
     // array the HTTP verbs that are supported by the resource URL
     $action->run($id);
 }
 /**
  * @inheritdoc
  */
 public function actions()
 {
     $actions = parent::actions();
     $actions['index'] = ['class' => IndexAction::className(), 'modelClass' => $this->modelClass, 'formClass' => $this->indexFormClass, 'checkAccess' => function ($actionName) {
         AccessActionControl::checkAccess("{$this->permissionPrefix}:index", ['actionName' => $actionName]);
     }];
     $actions['view'] = ['class' => ViewAction::className(), 'modelClass' => $this->modelClass, 'checkAccess' => function ($actionName, $model) {
         AccessActionControl::checkAccess("{$this->permissionPrefix}:view", ['actionName' => $actionName, 'model' => $model]);
     }];
     $actions['options'] = ['class' => OptionsAction::className()];
     return $actions;
 }
Example #3
0
 /**
  * @inheritdoc
  */
 public function actions()
 {
     $actions = ['index' => ['class' => \netis\crud\crud\IndexAction::className()], 'relation' => ['class' => \netis\crud\crud\RelationAction::className()], 'view' => ['class' => \netis\crud\crud\ViewAction::className()], 'update' => ['class' => \netis\crud\crud\UpdateAction::className(), 'createScenario' => $this->createScenario, 'updateScenario' => $this->updateScenario], 'delete' => ['class' => \netis\crud\crud\DeleteAction::className()], 'options' => ['class' => \yii\rest\OptionsAction::className()], 'help' => ['class' => HelpAction::className(), 'viewPrefix' => 'help', 'defaultView' => 'index.md']];
     $helpAction = Yii::createObject($actions['help'], ['help', $this]);
     try {
         $helpAction->run();
     } catch (NotFoundHttpException $e) {
         unset($actions['help']);
     }
     foreach ($this->actionsClassMap as $id => $action) {
         if (!isset($actions[$id])) {
             $actions[$id] = [];
         }
         if (is_string($action)) {
             $actions[$id]['class'] = $action;
         } else {
             unset($action['verbs']);
             $actions[$id] = array_merge($actions[$id], $action);
         }
     }
     return $actions;
 }