1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- <?php
- namespace app\controllers;
- use app\models\base\Comments;
- use app\models\base\NewsTopic;
- use app\models\base\Story;
- use app\models\front\News;
- use yii\db\Expression;
- use yii\helpers\ArrayHelper;
- use yii\helpers\Url;
- use yii\web\Controller;
- use yii\web\NotFoundHttpException;
- use yii\web\Response;
- use \app\helpers\Uuid;
- class AmpController extends Controller
- {
- public $scripts;
- public function actionIndex($topic=NULL)
- {
- throw new NotFoundHttpException("Нет страницы");
- return $this->render("index");
- }
- /**
- * @param int $id
- */
- public function actionNews(int $id) {
- $model = $this->findModel($id);
- if(!$model instanceof News) throw new NotFoundHttpException("Новость не найдена");
- $this->layout = 'amp';
- $queryString = \Yii::$app->request->queryString?'?'.\Yii::$app->request->queryString:'';
- return $this->render('view',['model'=>$model]);
- }
- private function findModel($id)
- {
- return News::find()->andWhere(['id'=>$id])->limit(1)->one();
- }
- }
|