/** * @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'); } }
/** * @return \Flame\CMS\PostBundle\Forms\Categories\CategoryForm */ protected function createComponentCategoryForm() { $default = array(); if ($this->category instanceof \Flame\CMS\PostBundle\Model\Categories\Category) { $default = $this->category->toArray(); } $form = $this->categoryFormFactory->create($default); $form->setCategories($this->categoryFacade->getLastCategories()); if ($this->category) { $form->onSuccess[] = $this->lazyLink('this'); } else { $form->onSuccess[] = $this->lazyLink('default'); } return $form; }
/** * @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 null $data * @return CategoryControl */ public function create($data = null) { $control = new CategoryControl(); $control->setItems($this->categoryFacade->getLastCategories()); return $control; }