コード例 #1
0
 public function load(ObjectManager $manager)
 {
     $question = $this->getReference('question1');
     $options = array(array('value' => 'option1'), array('value' => 'option2'), array('value' => 'option3'));
     foreach ($options as $data) {
         $option = new Option();
         $option->setValue($data['value'])->setQuestion($question);
         $this->addReference('option-' . $data['value'], $option);
         $manager->persist($option);
     }
     $manager->flush();
 }
コード例 #2
0
 public function load(ObjectManager $manager)
 {
     $questionData = array('question1', 'question2');
     $options = array(array('value' => 'option1'), array('value' => 'option2'));
     foreach ($questionData as $key => $questionSubject) {
         $question = $this->getReference($questionSubject);
         foreach ($options as $optionKey => $data) {
             if ($key <= $optionKey) {
                 $option = new Option();
                 $option->setValue($data['value'])->setQuestion($question);
                 $this->addReference($questionSubject . '-option-' . $data['value'], $option);
                 $manager->persist($option);
             }
         }
     }
     $manager->flush();
 }
コード例 #3
0
 public function load(ObjectManager $manager)
 {
     $petition = $this->getReference('representativePetitionPublished1');
     $user1 = $this->getReference('user-mobile1');
     $signOption = new Option();
     $signOption->setValue('sign');
     $petition->addOption($signOption);
     $manager->persist($signOption);
     $answer = new Answer();
     $answer->setQuestion($petition);
     $answer->setPrivacy(Answer::PRIVACY_PUBLIC);
     $answer->setUser($user1);
     $answer->setComment('Test comment');
     $answer->setOption($signOption);
     $manager->persist($answer);
     $petition->addAnswer($answer);
     $manager->persist($petition);
     $manager->flush();
 }
コード例 #4
0
 /**
  * @Given /^There are published questions$/
  */
 public function thereArePublishedQuestions(TableNode $table)
 {
     $em = $this->getEm();
     $hash = $table->getHash();
     foreach ($hash as $row) {
         $class = 'Civix\\CoreBundle\\Entity\\Poll\\Question\\' . $row['type'];
         /* @var $entity \Civix\CoreBundle\Entity\Poll\Question */
         $entity = new $class();
         $entity->setSubject($row['subject']);
         $entity->setPublishedAt(new \DateTime());
         $expire = new \DateTime();
         $expire->add(new \DateInterval('P1D'));
         $entity->setExpireAt($expire);
         $entity->setUser($em->getRepository('Civix\\CoreBundle\\Entity\\' . $row['owner'])->findOneByUsername($row['username']));
         foreach (range(1, 2) as $value) {
             $option = new Option();
             $option->setValue($value);
             $entity->addOption($option);
         }
         $em->persist($entity);
         $em->flush($entity);
     }
 }
 public function setValue($value)
 {
     $this->__load();
     return parent::setValue($value);
 }