Example #1
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     $skin = $this->skinAsset;
     if ($skin) {
         $skin::register($this->view);
     }
     CommentsAsset::register($this->view);
     $parent = Model::findOne(TActiveRecord::ROOT_ID);
     $query = $parent->children()->published()->andWhere(["model" => $this->modelClass, "item_id" => $this->itemId]);
     if (is_callable($this->queryModifier)) {
         $func = $this->queryModifier;
         $func($query);
     }
     $config = array_merge(['class' => ActiveDataProvider::className(), "query" => $query], $this->dataProviderConfig);
     $this->dataProvider = Yii::createObject($config);
     $this->dataProvider->getPagination()->pageSize = $this->pageSize;
     $id = $this->getId();
     $this->view->registerJs("\$('#{$id}').commentsWidget()");
 }