Backend\Modules\Search\Engine\Model::updateSynonym PHP Method

updateSynonym() public static method

Update a synonym
public static updateSynonym ( array $item )
$item array The data to update in the db.
    public static function updateSynonym($item)
    {
        // update
        BackendModel::getContainer()->get('database')->update('search_synonyms', $item, 'id = ?', array($item['id']));
        // invalidate the cache for search
        self::invalidateCache();
    }

Usage Example

Esempio n. 1
0
 /**
  * Validate the form
  */
 private function validateForm()
 {
     // is the form submitted?
     if ($this->frm->isSubmitted()) {
         // cleanup the submitted fields, ignore fields that were added by hackers
         $this->frm->cleanupFields();
         // validate fields
         $this->frm->getField('synonym')->isFilled(BL::err('SynonymIsRequired'));
         $this->frm->getField('term')->isFilled(BL::err('TermIsRequired'));
         if (BackendSearchModel::existsSynonymByTerm($this->frm->getField('term')->getValue(), $this->id)) {
             $this->frm->getField('term')->addError(BL::err('TermExists'));
         }
         // no errors?
         if ($this->frm->isCorrect()) {
             // build item
             $item['id'] = $this->id;
             $item['term'] = $this->frm->getField('term')->getValue();
             $item['synonym'] = $this->frm->getField('synonym')->getValue();
             $item['language'] = BL::getWorkingLanguage();
             // update the item
             BackendSearchModel::updateSynonym($item);
             // trigger event
             BackendModel::triggerEvent($this->getModule(), 'after_edit_synonym', array('item' => $item));
             // everything is saved, so redirect to the overview
             $this->redirect(BackendModel::createURLForAction('Synonyms') . '&report=edited-synonym&var=' . rawurlencode($item['term']) . '&highlight=row-' . $item['id']);
         }
     }
 }