private function initVoc($id, $flush_cache = FALSE)
 {
     // load voc data and terms and write them to $this->vocs
     // @todo implement it
     if ($flush_cache) {
         self::$vocs = array();
     }
     if (array_key_exists($id, self::$vocs)) {
         return;
     }
     $voc = SpecTermsVoc::findOne(['id' => $id]);
     self::$vocs[$id] = $voc->attributes;
     self::$vocs[$id]['terms'] = array();
     $terms = SpecTerm::find()->where(['vocabulary_id' => $voc->id])->all();
     foreach ($terms as $term) {
         $term_data = $term->attributes;
         $term_data['synonyms'] = [];
         $synonyms = $term->synonyms;
         foreach ($synonyms as $synonym) {
             $term_data['synonyms'][] = $synonym->name;
         }
         self::$vocs[$id]['terms'][] = $term_data;
     }
 }
 public function actionVocFindTerms($voc_id, $term_name = '')
 {
     $voc = SpecTermsVoc::findOne(['id' => $voc_id]);
     if (empty($voc)) {
         echo "Vocabulary with id {$voc_id} not exists\n";
         return;
     }
     $where = array('vocabulary_id' => $voc_id);
     if (!empty($term_name)) {
         $where['name'] = $term_name;
     }
     $terms = SpecTerm::find()->where($where)->all();
     echo "id | name | synonyms \n";
     array_filter($terms, function ($term) {
         echo "{$term->id} | {$term->name} ";
         foreach ($term->synonyms as $synonym) {
             echo "| {$synonym->name}";
         }
         echo "\n";
     });
 }