Пример #1
0
 /**
  * @param $id
  */
 public function handleMarkPublish($id)
 {
     if (!$this->getUser()->isAllowed('Admin:Post', 'publish')) {
         $this->flashMessage('Access denied');
     } else {
         try {
             $this->postManager->changePublicState($id);
         } catch (\Nette\InvalidArgumentException $ex) {
             $this->flashMessage($ex->getMessage());
         }
     }
     $this->redirect('this');
 }
Пример #2
0
 /**
  * @param PostForm $form
  */
 public function formSubmitted(PostForm $form)
 {
     $values = $form->getValues();
     $values->category = $this->categoryFacade->getOne($values->category);
     $tags = array();
     if (count($values->tags)) {
         foreach ($values->tags as $tagId) {
             $tags[] = $this->tagFacade->getOne($tagId);
         }
     }
     $values->tags = $tags;
     try {
         $this->postManager->update($values);
         $form->presenter->flashMessage('Post management was successful', 'success');
     } catch (\Nette\InvalidArgumentException $ex) {
         $form->addError($ex->getMessage());
     }
 }