/** * @param $id */ public function actionPosts($id) { if ($category = $this->categoryFacade->getOne($id)) { $this->template->category = $category; $this->posts = $category->getPosts()->toArray(); if (!count($this->posts)) { $this->setView('none'); } } else { $this->setView('notFound'); } }
/** * @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()); } }
/** * @param $id */ public function actionUpdate($id = null) { $this->category = $this->categoryFacade->getOne($id); $this->template->category = $this->category; }