frontend/controllers/PageController.php
<?php
/*
* This file is part of the HomeFinanceV2 project.
*
* (c) Rafalsky.com <http://github.com/Rafalsky/>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace frontend\controllers;
use common\models\Page;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
class PageController extends Controller
{
public function actionView($slug)
{
$model = Page::find()->where(['slug' => $slug, 'status'=>Page::STATUS_PUBLISHED])->one();
if (!$model) {
throw new NotFoundHttpException(\Yii::t('frontend', 'Page not found'));
}
$viewFile = $model->view ?: 'view';
return $this->render($viewFile, ['model' => $model]);
}
}