public function actionSingle()
 {
     $model = new CommentForm();
     $blog = Blog::getInstance();
     $uri = \Yii::$app->request->get('uri');
     $article = Articles::findOne(['id' => \Yii::$app->request->get('id')]);
     if (!$article) {
         \Yii::$app->session->setFlash('articleNotFound', 'warning');
         // Look at UrlManager configurations
         // Real address is['/blog/category?uri=' . $uri]
         return $this->redirect(['/category/' . $uri], 302);
     }
     $articleCatUri = $article->category->uri;
     $articleId = $article->id;
     if ($articleCatUri != $uri) {
         // Look at UrlManager configurations
         // Real address is ['/blog/single?uri=' . $articleCatUri . '&id=' . $articleId]
         return $this->redirect(['/category/' . $articleCatUri . '/' . $articleId], 302);
     }
     if ($model->load(\Yii::$app->request->post()) && $model->validate()) {
         $model->article_id = $articleId;
         $answer = $model->addComment() ? ['name' => 'commentSuccessSending', 'type' => 'success'] : ['name' => 'commentWarningSending', 'type' => 'error'];
         \Yii::$app->session->setFlash($answer['name'], $answer['type']);
         return $this->refresh();
     }
     $data = $blog->getComments($articleId);
     return $this->render('single', ['article' => $article, 'model' => $model, 'data' => $data]);
 }
 /**
  * /snippets/language-slug/snippet-slug/comment
  *
  * @return string
  */
 public function actionComment()
 {
     if (!$this->parseQueryParams()) {
         return $this->goHome();
     }
     $model = new CommentForm();
     if ($this->request->method == 'POST') {
         // populate model attributes with user inputs
         $model->load($this->request->post());
         if ($model->validate() && $model->save($this->member, $this->snippet)) {
             $this->notifySuccess('Your comment has been added.');
         } else {
             $this->notifyError('Could not add your comment.');
         }
     }
     return $this->redirect('/snippets/' . $this->language->slug . '/' . $this->snippet->slug);
 }