/** * @param string Diskova cesta k www adresari * @param \App\Model\Repository\ArticleRepository $repository * @param BaseFormFactory $baseFormFactory Tovarna se zakladni formularem */ public function __construct(\App\Model\ArticleImageStorage $imageStorage, \App\Model\Repository\ArticleRepository $repository, \App\Forms\BaseFormFactory $baseFormFactory) { $this->repository = $repository; $this->em = $repository->getEntityManager(); $this->baseFormFactory = $baseFormFactory; $this->imageStorage = $imageStorage; }
/** * @param int $articleId * @return void Odstranuje propojeni clanku a ankety */ public function handleDeleteArticleVote($articleId) { $em = $this->articleRepository->getEntityManager(); $rArticle = $em->getReference(Model\Entities\Article::class, $articleId); $this->myVote->removeArticle($rArticle); $em->flush(); $this->redirect('this'); }
/** * @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'); }