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

getSynonym() public static method

Get a synonym
public static getSynonym ( integer $id ) : array
$id integer The id of the item we're looking for.
return array
    public static function getSynonym($id)
    {
        return (array) BackendModel::getContainer()->get('database')->getRecord('SELECT *
             FROM search_synonyms
             WHERE id = ?', array((int) $id));
    }

Usage Example

Example #1
0
 /**
  * Execute the action
  */
 public function execute()
 {
     // get parameters
     $this->id = $this->getParameter('id', 'int');
     // does the item exist
     if ($this->id !== null && BackendSearchModel::existsSynonymById($this->id)) {
         // call parent, this will probably add some general CSS/JS or other required files
         parent::execute();
         // get data
         $this->record = (array) BackendSearchModel::getSynonym($this->id);
         // delete item
         BackendSearchModel::deleteSynonym($this->id);
         // trigger event
         BackendModel::triggerEvent($this->getModule(), 'after_delete_synonym', array('id' => $this->id));
         // item was deleted, so redirect
         $this->redirect(BackendModel::createURLForAction('Synonyms') . '&report=deleted-synonym&var=' . rawurlencode($this->record['term']));
     } else {
         $this->redirect(BackendModel::createURLForAction('Synonyms') . '&error=non-existing');
     }
 }
All Usage Examples Of Backend\Modules\Search\Engine\Model::getSynonym