PageController.php
990 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
namespace frontend\controllers;
use artbox\core\models\Page;
use yii\helpers\Json;
use yii\helpers\Url;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
/**
* Class PageController
*
* @package frontend\controllers
*/
class PageController extends Controller
{
public function actionView($id)
{
$model = $this->findModel($id);
var_dump(Url::to(Json::decode($model->lang->alias->route)));
return $this->render(
'view',
[
'model' => $model,
]
);
}
protected function findModel($id)
{
$model = Page::findOne($id);
if (!empty($model)) {
return $model;
} else {
throw new NotFoundHttpException('Model not found');
}
}
}