/**
  * @return static
  */
 public function getTerms()
 {
     return $this->hasMany(TaxonomyTerm::className(), ['vid' => 'id'])->inverseOf('vocabulary');
 }
Example #2
0
 /**
  * @param TaxonomyTerm $child
  */
 public function addChild(self &$child)
 {
     $this->_child[$child->id] = $child->setParent($this);
 }
 /**
  * Populates an auth item with the data fetched from database
  * @param array $row the data from the auth item table
  * @return TaxonomyTerm the populated auth item instance (either Role or Permission)
  */
 protected static function populateItem($row)
 {
     return TaxonomyTerm::create(['id' => $row['id'], 'vid' => $row['vid'], 'name' => $row['name'], 'description' => $row['description']]);
 }
Example #4
0
 /**
  * Find model by ID.
  *
  * @param integer|array $id Model ID
  *
  * @return TaxonomyTerm
  *
  * @throws HttpException 404 error if model not found
  */
 protected function findModel($id, $vid)
 {
     if (is_array($id)) {
         $model = TaxonomyTerm::find()->where(['vid' => $vid, 'id' => $id])->all();
     } else {
         $model = TaxonomyTerm::find()->where(['vid' => $vid, 'id' => $id])->one();
     }
     if ($model !== null) {
         return $model;
     } else {
         throw new HttpException(404);
     }
 }