1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- <?php
- namespace app\controllers;
- use app\models\base\NewsTopic;
- use app\models\News;
- use yii\web\Controller;
- use yii\web\NotFoundHttpException;
- class VideoController extends Controller
- {
- //public $viewTheme = "dark";
- public function actionIndex($topic=NULL)
- {
- $topic_id = 128;
- return $this->render("index",["topic_id"=>$topic_id]);
- }
- /**
- * @param int $id
- * @return string
- */
- public function actionView(int $id):string {
- $model = $this->findModel($id);
- if(!$model instanceof News) throw new NotFoundHttpException("Новость не найдена");
- return $this->render('view',['model'=>$model]);
- }
- public function actionStoryslugView($storyslug):string
- {
- $model = News::find()->andWhere(['alias'=>$storyslug])->one();
- if(!$model instanceof News) throw new NotFoundHttpException("Новость не найдена");
- return $this->render('view',['model'=>$model]);
- }
- private function findModel($id)
- {
- return News::find()->andWhere(['id'=>$id])->one();
- }
- public function actionTopic($topic){
- $topic = str_replace("/","",$topic);
- $topic = NewsTopic::find()->andWhere(['url'=>$topic])->one();
- if(!$topic instanceof NewsTopic) throw new NotFoundHttpException("Страница не найдена");
- return $this->render("archive/index",["topic"=>$topic]);
- }
- }
|