Exemplo n.º 1
0
 /**
  * Odstraneni konkretni ankety, vcetne odpovedi
  * @param \App\Model\Entities\Vote $vote
  * @return boolean
  */
 public function deleteVote(Entities\Vote $vote)
 {
     try {
         $options = $vote->getOptions();
         //odstraneni ankety/otazky
         $this->em->remove($vote);
         //odstraneni odpovedi otazky
         foreach ($options as $option) {
             if ($option !== NULL) {
                 $this->em->remove($option);
             }
         }
         //provedeni zmen
         $result = $this->em->flush();
     } catch (\Doctrine\ORM\ORMException $e) {
         Debugger::log($e, Debugger::INFO);
         $result = FALSE;
     }
     return $result;
 }
Exemplo n.º 2
0
 /**
  * @param \App\Model\Entities\Vote $vote
  * @return array Vychozi hodnoty pro formular
  */
 protected function getDefaults($vote)
 {
     $result = [];
     $result['id'] = $vote->getId();
     $result['question'] = $vote->getQuestion();
     $result['type'] = $vote->getTypeVote()->getId();
     $expiration = $vote->getExpire();
     if ($expiration) {
         $result['expiration'] = $vote->getExpire()->format(self::$dateMask);
     }
     $options = $vote->getOptions();
     $result['options'] = [];
     $i = 1;
     //containery v replicatoru se cislu od jednicky
     foreach ($options as $option) {
         $result['options'][$i] = ['option' => $option->getValue()];
         $i++;
     }
     //$result['options']
     return $result;
 }