public function actionRead($id)
 {
     $taxonomy = Taxonomy::findByIdOrSlug($id);
     $children = $taxonomy->children()->all();
     $ids = ArrayHelper::getColumn($children, "taxonomy_id");
     array_unshift($ids, $taxonomy->getPrimaryKey());
     $dataProvider = new ActiveDataProvider(['query' => TaxonomyIndex::find()->select(['entity', 'entity_id'])->distinct()->where(["taxonomy_id" => $ids])->orderBy(['taxonomy_index_id' => SORT_DESC]), 'pagination' => ['pageSize' => 15]]);
     list($title, $desc, $keys) = $taxonomy->getMetaData();
     $this->getView()->setMetaData($title, $desc, $keys);
     return $this->render('view', ['taxonomyIndexs' => $dataProvider->getModels(), "pagination" => $dataProvider->getPagination(), "taxonomy" => $taxonomy]);
 }
 /**
  * Get cached tree structure of category objects
  *
  * @return array
  */
 public function getTaxonomytree()
 {
     if ($this->root != null) {
         $countries = Taxonomy::findOne(['slug' => $this->root]);
         $collection = $countries->children()->asArray()->all();
     } else {
         $collection = Taxonomy::find()->sort()->asArray()->all();
     }
     $indexs = TaxonomyIndex::find()->where(["entity_id" => $this->getEntityId(), "entity" => $this->getEntityClass()])->asArray()->all();
     $indexs = ArrayHelper::getColumn($indexs, "taxonomy_id");
     $trees = NestedSetsTree::generateTree($collection, function ($item) use($indexs) {
         $item["checked"] = false;
         if (in_array($item["taxonomy_id"], $indexs)) {
             $item["checked"] = true;
         }
         return $item;
     });
     return $trees;
 }