/** * @param Form $form * @return void Zpracovani formulare - pridani noveho komentare */ public function formSucceeded(Form $form) { //nacteni a smazani session $values = \Nette\Utils\ArrayHash::from($this->commentSession->content); $this->commentSession->remove(); //ulozit novy prispevek ke clanku $this->article = $this->articleRepository->getById($values->articleId); if (isset($this->myUser)) { $values->user = $this->myUser; $values->name = NULL; } else { $values->user = NULL; } //vytvoreni komentu, prirazeni ke clanku a ulozeni $newComment = new \App\Model\Entities\Comment($this->article, $values->user, $values->name, $values->content); $this->articleRepository->getEntityManager()->persist($newComment); $this->article->addComment($newComment); $this->articleRepository->getEntityManager()->flush(); $this->redirect('this'); }