/** * Find project model by identifier. * * Throws 404 if not found. * * @param integer $id * @return Project * @throws NotFoundHttpException */ protected function findModel($id) { $model = is_scalar($id) ? Project::findOne($id) : null; if (!$model instanceof Project) { throw new NotFoundHttpException(); } return $model; }
/** * @inheritdoc */ public function init() { // find a project using id request variable $projectId = Yii::$app->request->get('id', null); if (is_scalar($projectId)) { $this->project = Project::findOne((int) $projectId); } if (!$this->project instanceof Project) { throw new NotFoundHttpException(); } $this->repository = $this->project->getRepositoryObject(); return parent::init(); }
/** * Get project model * * Throws 404 if project not found. * * @param integer $projectId Project identifier * * @return Project * * @throws NotFoundHttpException */ protected function findProject($projectId) { $project = Project::findOne((int) $projectId); if (!$project instanceof Project) { throw new NotFoundHttpException(Yii::t('project', 'Project not found')); } return $project; }