protected function findFlatPage($id) { $flatPage = FlatPage::findOne($id); if (!isset($flatPage)) { throw new HttpException(404, Yii::t('app', 'The requested page does not exist.')); } return $flatPage; }
public function actionCommonFlatPage($url) { $flatPage = FlatPage::findOne(['url' => $url]); $this->flatPage = $flatPage; try { return $this->render($url, compact('flatPage')); } catch (\yii\base\InvalidParamException $ex) { Yii::trace("View not found for flatPage {$url}, using default view."); } return $this->render('default_page', compact('flatPage')); }
public static function getUrlFor($flatPageUrl) { $flatPage = FlatPage::findOne(['url' => $flatPageUrl]); return isset($flatPage) ? $flatPage->getUrl() : '#'; }