Esempio n. 1
0
 /**
  * Return array of synonyms for words
  *
  * @param array $arWord
  * @return array
  */
 public function getSynonymsByWord($arWord)
 {
     $result = [];
     if (!is_array($arWord)) {
         $arWord = [$arWord];
     }
     $collection = $this->collectionFactory->create();
     foreach ($arWord as $word) {
         $collection->getSelect()->orWhere('term = ?', $word);
     }
     /** @var Synonym $model */
     foreach ($collection as $model) {
         $synonyms = explode(',', $model->getSynonyms());
         foreach ($arWord as $word) {
             if ($model->getTerm() === $word) {
                 foreach ($synonyms as $synonym) {
                     $result[$word][$synonym] = $synonym;
                 }
             }
         }
     }
     return $result;
 }
Esempio n. 2
0
 /**
  * {@inheritdoc}
  */
 protected function _prepareCollection()
 {
     $this->setCollection($this->collectionFactory->create());
     return parent::_prepareCollection();
 }