/**
  * Create comment.
  */
 public function actionCreate()
 {
     $model = new Comment(['scenario' => 'create']);
     Yii::$app->response->format = Response::FORMAT_JSON;
     if ($model->load(Yii::$app->request->post())) {
         if ($model->validate()) {
             $modelClass = Model::findOne(['id' => Yii::$app->request->post('Comment')['model_class']]);
             //Проверяем может ли пользователь оставлять комментарий
             if (method_exists($modelClass->name, 'checkCanComment')) {
                 $canComment = call_user_func_array([$modelClass->name, 'checkCanComment'], [Yii::$app->request->post('Comment')['model_id'], Yii::$app->getUser()->id, $model->parent_id]);
             } else {
                 $canComment = true;
             }
             if ($canComment && $model->save(false)) {
                 if (Yii::$app->getModule('comments')->allowRate && Yii::$app->request->post('rating') !== null) {
                     if (!Yii::$app->request->post('Comment')['parent_id']) {
                         $modelDestination = call_user_func([$modelClass->name, 'findOne'], [Yii::$app->request->post('Comment')['model_id']]);
                         call_user_func_array([Yii::$app->getModule('comments')->ratePath . 'Rate', 'setRating'], [$modelDestination, Yii::$app->request->post('rating'), $model]);
                         /*Rate::setRating($modelDestination,
                           Yii::$app->request->post('rating'), $model);*/
                     }
                 }
                 return $this->tree($model);
             } else {
                 Yii::$app->response->setStatusCode(500);
                 return Module::t('comments', 'FRONTEND_FLASH_FAIL_CREATE');
             }
         } elseif (Yii::$app->request->isAjax) {
             Yii::$app->response->setStatusCode(400);
             return ActiveForm::validate($model);
         }
     }
 }