Пример #1
0
 /**
  * @param VoteRepository $voteRepository
  * @param ArticleRepository $articleRepository
  * @param BaseFormFactory $baseFormFactory Tovarna se zakladni formularem
  */
 public function __construct(VoteRepository $voteRepository, ArticleRepository $articleRepository, BaseFormFactory $baseFormFactory)
 {
     $this->baseFormFactory = $baseFormFactory;
     $this->voteRepository = $voteRepository;
     $this->articleRepository = $articleRepository;
     $this->em = $voteRepository->getEntityManager();
 }
Пример #2
0
 /**
  * @param int $voteId vote_id, pkey ankety
  */
 public function actionArticles($voteId)
 {
     $this->myVote = $this->voteRepository->getById($voteId);
     if (!$this->myVote) {
         $this->flashMessage($this->translator->translate('system.invalidId'), self::MESSAGE_DANGER);
         $this->redirect('default');
     }
 }
Пример #3
0
 /**
  * @param Nette\Utils\ArrayHash $values Hodnoty z formulare
  * @return boolean Editace provedena uspesne?
  */
 protected function editVote($values)
 {
     $result = TRUE;
     try {
         /** @var \App\Model\Entities\Vote $editVote */
         $editVote = $this->repository->getById($values->id);
         if (!$editVote) {
             return FALSE;
         }
         // nastaveni atributu
         $editVote->setQuestion($values->question);
         $editVote->setExpire($values->expiration);
         if ($editVote->getTypeVote()->getId() !== $values->type) {
             $typeVote = $this->em->getReference(\App\Model\Entities\TypeVote::class, $values->id);
             $editVote->setTypeVote($typeVote);
         }
         $options = [];
         foreach ($values->options as $option) {
             if (empty($option->option)) {
                 continue;
             }
             $options[] = $option->option;
         }
         $result = $editVote->setOptions($options);
         foreach ($result['remove'] as $removeOption) {
             if ($removeOption === NULL) {
                 continue;
             }
             $this->em->remove($removeOption);
         }
         //ulozeni zmeny
         $this->em->flush();
     } catch (\Exception $e) {
         \Tracy\Debugger::log($e, \Tracy\Debugger::INFO);
         $result = FALSE;
     }
     return $result;
 }
Пример #4
0
 /**
  * Nastaveni anketni otazky
  * @param Vote $vote
  */
 public function setVote($vote)
 {
     $this->vote = $this->repository->getById($vote);
 }