getCategory() public static méthode

Fetch a category
public static getCategory ( integer $id ) : array
$id integer
Résultat array
Exemple #1
0
 /**
  * Execute the action
  */
 public function execute()
 {
     $this->id = $this->getParameter('id', 'int');
     // does the item exist
     if ($this->id !== null && BackendFaqModel::existsCategory($this->id)) {
         $this->record = (array) BackendFaqModel::getCategory($this->id);
         if (BackendFaqModel::deleteCategoryAllowed($this->id)) {
             parent::execute();
             // delete item
             BackendFaqModel::deleteCategory($this->id);
             BackendModel::triggerEvent($this->getModule(), 'after_delete_category', array('item' => $this->record));
             // category was deleted, so redirect
             $this->redirect(BackendModel::createURLForAction('Categories') . '&report=deleted-category&var=' . urlencode($this->record['title']));
         } else {
             $this->redirect(BackendModel::createURLForAction('Categories') . '&error=delete-category-not-allowed&var=' . urlencode($this->record['title']));
         }
     } else {
         $this->redirect(BackendModel::createURLForAction('Categories') . '&error=non-existing');
     }
 }
Exemple #2
0
 /**
  * Execute the action
  */
 public function execute()
 {
     parent::execute();
     // get parameters
     $newIdSequence = trim(\SpoonFilter::getPostValue('new_id_sequence', null, '', 'string'));
     // list id
     $ids = (array) explode(',', rtrim($newIdSequence, ','));
     // loop id's and set new sequence
     foreach ($ids as $i => $id) {
         // define category
         $category = BackendFaqModel::getCategory((int) $id);
         // update sequence
         if ($category) {
             // change sequence
             $category['sequence'] = $i + 1;
             // update category
             BackendFaqModel::updateCategory($category);
         }
     }
     // success output
     $this->output(self::OK, null, 'sequence updated');
 }
Exemple #3
0
 /**
  * Get the data
  */
 private function getData()
 {
     $this->record = BackendFaqModel::getCategory($this->id);
 }