AmpController.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace app\controllers;
  3. use app\models\base\Comments;
  4. use app\models\base\NewsTopic;
  5. use app\models\base\Story;
  6. use app\models\front\News;
  7. use yii\db\Expression;
  8. use yii\helpers\ArrayHelper;
  9. use yii\helpers\Url;
  10. use yii\web\Controller;
  11. use yii\web\NotFoundHttpException;
  12. use yii\web\Response;
  13. use \app\helpers\Uuid;
  14. class AmpController extends Controller
  15. {
  16. public $scripts;
  17. public function actionIndex($topic=NULL)
  18. {
  19. throw new NotFoundHttpException("Нет страницы");
  20. return $this->render("index");
  21. }
  22. /**
  23. * @param int $id
  24. */
  25. public function actionNews(int $id) {
  26. $model = $this->findModel($id);
  27. if(!$model instanceof News) throw new NotFoundHttpException("Новость не найдена");
  28. $this->layout = 'amp';
  29. $queryString = \Yii::$app->request->queryString?'?'.\Yii::$app->request->queryString:'';
  30. return $this->render('view',['model'=>$model]);
  31. }
  32. private function findModel($id)
  33. {
  34. return News::find()->andWhere(['id'=>$id])->limit(1)->one();
  35. }
  36. }