For more details and usage information on ViewAction, see the guide article on rest controllers.
Since: 2.0
Author: Qiang Xue (qiang.xue@gmail.com)
Inheritance: extends Action
Exemplo n.º 1
0
 /**
  * @inheritdoc
  */
 public function run($id)
 {
     $model = parent::findModel($id);
     // Check for current user
     if ($model->user->primaryKey != Yii::$app->user->identity->primaryKey) {
         throw new ServerErrorHttpException('View this object is forbidden.');
     }
     return $model;
 }
Exemplo n.º 2
0
 public function run($id)
 {
     $model = parent::run($id);
     foreach ($this->controller->getFilters() as $column => $value) {
         if ($model->{$column} != $value) {
             throw new NotFoundHttpException("Object not found: {$id}");
         }
     }
     return $model;
 }
Exemplo n.º 3
0
 /**
  * @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;
 }
Exemplo n.º 4
0
 public function run($id)
 {
     return parent::run($id);
 }
Exemplo n.º 5
0
 /**
  * @inheritdoc
  */
 public function run()
 {
     return parent::run(null);
 }