Exemplo n.º 1
0
 /**
  * 
  * @param string}string[] $word
  * @return \static
  */
 public function word($word, $like = false)
 {
     if (is_string($word)) {
         return $this->likeCondition($word, Synonym::tableName() . '.word', $like);
     }
     return $this->andWhere([Synonym::tableName() . '.word' => $word]);
 }
Exemplo n.º 2
0
 /**
  * Synonyms generator.
  * @param string|\rhoone\extension\Extension|\rhoone\models\Extension|mixed $class
  * `string` if extension class.
  * @param string[] $words
  * @throws InvalidParamException
  */
 public function getSynonyms($class = null, $words = [])
 {
     // Method One:
     $query = Synonym::find();
     if (is_array($words) && !empty($words)) {
         $query = $query->word($words);
     }
     if (!($class === null || $class === false || is_string($class) && empty($class))) {
         $query = $query->extension($class);
     }
     foreach ($query->all() as $synonyms) {
         (yield $synonyms);
     }
     // Method Two:
     //return Synonym::find()->all();
 }
Exemplo n.º 3
0
 /**
  * Remove all synonyms.
  * @return integer the number of synonyms deleted.
  */
 public function removeAllSynonyms()
 {
     return Synonym::deleteAll(['headword_guid' => $this->guid]);
 }
Exemplo n.º 4
0
 /**
  * 
  * @return SynonymQuery
  */
 public function getSynonyms()
 {
     return $this->hasMany(Synonym::className(), ['headword_guid' => 'guid'])->via('headwords');
 }