Ejemplo n.º 1
0
 /**
  * @return TaxonomyTerm[]|array
  */
 protected function getTerms()
 {
     if (empty($this->_terms)) {
         $vocabularies = TaxonomyVocabulary::getModelsArray();
         if (isset($vocabularies[$this->vocabularyName])) {
             $this->_terms = TaxonomyTermHierarchy::getTree($vocabularies[$this->vocabularyName]->id);
         }
     }
     return $this->_terms;
 }
Ejemplo n.º 2
0
 /**
  * @return static
  */
 public function getVocabulary()
 {
     return $this->hasOne(TaxonomyVocabulary::className(), ['id' => 'vid'])->inverseOf('terms');
 }
Ejemplo n.º 3
0
 /**
  * Find model by ID.
  *
  * @param integer|array $id Model ID
  *
  * @return TaxonomyVocabulary
  *
  * @throws HttpException 404 error if model not found
  */
 protected function findModel($id)
 {
     if (is_array($id)) {
         $model = TaxonomyVocabulary::findAll($id);
     } else {
         $model = TaxonomyVocabulary::findOne($id);
     }
     if ($model !== null) {
         return $model;
     } else {
         throw new HttpException(404);
     }
 }
Ejemplo n.º 4
0
 /**
  * Creates vocabulary
  * @param $name
  * @return TaxonomyVocabulary
  * @throws \yii\base\ErrorException
  */
 protected function createVocabularyByName($name)
 {
     return TaxonomyVocabulary::create($name);
 }