コード例 #1
0
 public function uninstall()
 {
     //drop the data table
     //$this->getDb()->createCommand()->dropTable($this->getTable())->execute();
     //delete the term itself
     $model = TaxonomyDef::findOne($this->id);
     $model->delete();
 }
コード例 #2
0
ファイル: Taxonomy.php プロジェクト: traykovn/yii2-taxonomy
 /**
  * @param $termName
  * @return BaseTerm
  * @throws InvalidConfigException
  * @throws TermNotDefinedException
  */
 public function getTerm($termName, $reload = false)
 {
     if (!isset($this->_taxonomy[$termName]) || $reload) {
         $tax = TaxonomyDef::findOne(['name' => $termName]);
         \Yii::getLogger()->log("Initialising term {$termName}", Logger::LEVEL_INFO, 'nkostadinov.taxonomy.terms');
         $this->_taxonomy[$termName] = \Yii::createObject($tax->attributes);
     }
     return $this->_taxonomy[$termName];
 }
コード例 #3
0
 /**
  * Finds the TaxonomyDef model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return TaxonomyDef the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = TaxonomyDef::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }