exists() public static method

Does an id exist.
public static exists ( integer $id ) : boolean
$id integer The id to check for existence.
return boolean
Example #1
0
 /**
  * Execute the action
  */
 public function execute()
 {
     $this->id = $this->getParameter('id', 'int');
     // does the item exists
     if ($this->id !== null && BackendLocaleModel::exists($this->id)) {
         parent::execute();
         $this->setFilter();
         $this->getData();
         $this->loadForm();
         $this->validateForm();
         $this->parse();
         $this->display();
     } else {
         $this->redirect(BackendModel::createURLForAction('Index') . '&error=non-existing');
     }
 }
Example #2
0
 /**
  * Execute the action
  */
 public function execute()
 {
     $this->id = $this->getParameter('id', 'int');
     // does the item exist
     if ($this->id !== null && BackendLocaleModel::exists($this->id) && BackendAuthentication::getUser()->isGod()) {
         parent::execute();
         // filter options
         $this->setFilter();
         // get data
         $this->record = (array) BackendLocaleModel::get($this->id);
         // delete item
         BackendLocaleModel::delete(array($this->id));
         // trigger event
         BackendModel::triggerEvent($this->getModule(), 'after_delete', array('id' => $this->id));
         // build redirect URL
         $redirectUrl = BackendModel::createURLForAction('Index') . '&report=deleted&var=' . urlencode($this->record['name'] . ' (' . strtoupper($this->record['language']) . ')') . $this->filterQuery;
         // item was deleted, so redirect
         $this->redirect($redirectUrl);
     } else {
         $this->redirect(BackendModel::createURLForAction('Index') . '&error=non-existing');
     }
 }