예제 #1
0
 public function update()
 {
     if (!empty($_REQUEST['label_id'])) {
         try {
             $label = new Label($_REQUEST['label_id']);
         } catch (\Exception $e) {
             $_SESSION['errorMessages'][] = $e;
             header('Location: ' . BASE_URL . '/labels');
             exit;
         }
     } else {
         $label = new Label();
     }
     if (isset($_POST['name'])) {
         $label->handleUpdate($_POST);
         try {
             $label->save();
             header('Location: ' . BASE_URL . '/labels');
             exit;
         } catch (\Exception $e) {
             $_SESSION['errorMessages'][] = $e;
         }
     }
     $this->template->blocks[] = new Block('labels/updateForm.inc', array('label' => $label));
 }
예제 #2
0
 /**
  * @param Label $l
  * @return bool
  */
 public function hasLabel(Label $l)
 {
     if ($this->getId()) {
         return in_array($l->getId(), array_keys($this->getLabels()));
     }
 }