AmpController.php 1013 B

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. return $this->render("index");
  20. }
  21. /**
  22. * @param int $id
  23. */
  24. public function actionNews(int $id) {
  25. $model = $this->findModel($id);
  26. if(!$model instanceof News) throw new NotFoundHttpException("Новость не найдена");
  27. $this->layout = 'amp';
  28. $queryString = \Yii::$app->request->queryString?'?'.\Yii::$app->request->queryString:'';
  29. return $this->render('view',['model'=>$model]);
  30. }
  31. private function findModel($id)
  32. {
  33. return News::find()->andWhere(['id'=>$id])->limit(1)->one();
  34. }
  35. }