Conditions | 2 |
Paths | 2 |
Total Lines | 31 |
Code Lines | 21 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
52 | public function actionView($alias) |
||
53 | { |
||
54 | $model = Page::find()->where([ |
||
55 | 'alias' => $alias |
||
56 | ])->andWhere([ |
||
57 | 'active' => 1 |
||
58 | ])->one(); |
||
59 | |||
60 | if (null === $model) { |
||
61 | throw new NotFoundHttpException('Page not fount with alias = '.$alias.'.'); |
||
62 | } |
||
63 | |||
64 | $this->setMetaParams($model); |
||
|
|||
65 | |||
66 | $articlesQuery = Article::find()->where([ |
||
67 | 'pageId' => $model->id |
||
68 | ])->andWhere([ |
||
69 | 'active' => 1 |
||
70 | ]); |
||
71 | |||
72 | $pagination = new Pagination([ |
||
73 | 'totalCount' => $articlesQuery->count(), |
||
74 | 'defaultPageSize' => Yii::$app->params['defaultPageSize'] |
||
75 | ]); |
||
76 | |||
77 | return $this->render('view', [ |
||
78 | 'model' => $model, |
||
79 | 'pagination' => $pagination, |
||
80 | 'articles' => $articlesQuery->offset($pagination->offset) |
||
81 | ->limit($pagination->limit) |
||
82 | ->all() |
||
83 | ]); |
||
86 |