/** * Finds the PostType model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * * @param integer $id * * @return PostType the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findPostType($id) { if (($model = PostType::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException(Yii::t('content', 'The requested page does not exist.')); } }
/** * Finds the Post model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * * @param $post_type * * @throws \yii\web\NotFoundHttpException * @return PostType the loaded model */ protected function findPostTypeBySlug($post_type) { $model = PostType::findOne(['post_type_slug' => $post_type]); if ($model) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }