/** * @inheritdoc */ public function run() { $class = $this->model; $class = sprintf("%u", crc32($class::className())); $models = Comment::getTree($this->model->id, $class, $this->author_id, $this->status, $this->options); $model = new Comment(['scenario' => 'create']); $model->model_class = $class; $model->model_id = $this->model->id; $count = Comment::getCountComments($this->model, $this->author_id); $lastUserComment = Comment::lastUserComment(Yii::$app->getUser()->id, $this->model, Comment::STATUS_ACTIVE); $viewPath = $this->viewPath !== null ? $this->viewPath : Yii::$app->getModule('comments')->widgetViewPath; return $this->render($viewPath . 'index', ['title' => $this->title, 'models' => $models, 'model' => $model, 'count' => $count, 'author_id' => $this->author_id, 'current_model' => $this->model, 'canComment' => $this->canComment, 'lastUserComment' => $lastUserComment]); }
/** * @param Comment $model Comment * * @return string Comments list */ protected function tree($model) { $viewPath = Yii::$app->request->post('viewPath'); $author_id = Yii::$app->request->post('author_id'); if ($viewPath === null) { $viewPath = Yii::$app->getModule('comments')->widgetViewPath; } $models = Comment::getTree($model->model_id, $model->model_class, $author_id); return $this->renderPartial($viewPath . '_index_item', ['models' => $models]); }