示例#1
0
 /**
  * @param Vote $vote
  * @param array $requestInfo
  * @param \Nette\Utils\ArrayHash $values
  * @return boolean Ulozeni hlasovani
  */
 protected function processPoll($vote, $requestInfo, $values)
 {
     $voter_id = \App\Model\Entities\Poll::generateVoteIdentificator();
     $answers = $this->parsePoll($values);
     foreach ($answers as $key => $value) {
         if ($key != 'text') {
             $myOption = $this->em->getReference(\App\Model\Entities\Option::class, $key);
         } else {
             $myOption = NULL;
         }
         $myNewPoll = new \App\Model\Entities\Poll($myOption, $value);
         $myNewPoll->setVoterIdentification($voter_id);
         $myNewPoll->setIp($requestInfo['ip']);
         $myNewPoll->setAgent($requestInfo['agent']);
         $myNewPoll->setCookie($requestInfo['cookie']);
         $vote->addPoll($myNewPoll);
     }
     try {
         $this->em->flush();
         $result = TRUE;
     } catch (\Exception $e) {
         \Tracy\Debugger::log($e, \Tracy\Debugger::INFO);
         $result = FALSE;
     }
     return $result;
 }