public function init() { $this->modelClass = UserProfile::className(); $this->findModel = UserController::className() . '::' . UserController::METHOD_FIND_MODEL; $this->checkAccess = UserController::className() . '::' . UserController::METHOD_CHECK_ACCESS; parent::init(); }
/** * @return bool * @throws \yii\web\ForbiddenHttpException */ public function beforeRun() { if ($this->needAuthorize && Yii::$app->user->isGuest) { HttpError::the403(); } return parent::beforeRun(); }
/** * @return string|array */ private function getRulesForAction() { if ($this->action->controller instanceof ActiveController) { return $this->getRulesForActiveAction($this->action); } if (!method_exists($this->action, 'rules')) { return ''; } return $this->action->rules(); }
public function findModel($id = null) { if (is_null($id)) { $modelClass = $this->modelClass; $emptyPrimaryKey = array_flip($modelClass::primaryKey()); $primaryKey = array_merge($emptyPrimaryKey, array_intersect_key(Yii::$app->getRequest()->getQueryParams(), $emptyPrimaryKey)); $id = implode(',', array_values($primaryKey)); } return parent::findModel($id); }
/** * @inheritdoc */ public function init() { parent::init(); $params = Yii::$app->request->queryParams; if ($this->expectedParams($params) === false) { throw new InvalidConfigException("unexpected configurations."); } $this->relativeClass = $params['relativeClass']; $this->relationName = $params['relationName']; $this->linkAttribute = $params['linkAttribute']; $this->relative_id = $params[$this->linkAttribute]; }
/** * check request for errors and load items */ public function init() { if (!$this->enable) { throw new MethodNotAllowedHttpException("Method Not Allowed"); } $this->items = Yii::$app->getRequest()->getBodyParam($this->property); if (!is_array($this->items)) { throw new BadRequestHttpException("{$this->property} must be array"); } if (count($this->items) > $this->limit) { throw new BadRequestHttpException("Request Entity Too Large", 413); } parent::init(); }
/** * @inheritdoc */ public function findModel($id) { $id = Uuid::str2uuid($id); return parent::findModel($id); }
/** * @inheritdoc */ public function init() { if ($this->controller instanceof ActiveController || $this->controller instanceof \yii\rest\ActiveController) { if ($this->modelClass === null) { $this->modelClass = $this->controller->modelClass; } if ($this->checkAccess === null) { $this->checkAccess = [$this->controller, 'checkAccess']; } } if ($this->viewName === null) { $this->viewName = $this->id; } parent::init(); }
/** * */ public function init() { parent::init(); }