public function createLink($name, $original) { $model = Taxonomy::findOne($original); if (empty($name)) { $name = $model->name; } return [$name, Util::getEntityUrl($model)]; }
/** * Finds the Taxonomy model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * * @param string $id * @return Taxonomy the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Taxonomy::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * 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; }