/**
  * Load data fixtures with the passed EntityManager
  *
  * @param ObjectManager $manager
  */
 public function load(ObjectManager $manager)
 {
     $ticketTypes = array(array('name' => 'Normal', 'longDescription' => 'De 12 ans à 59 ans', 'shortDescription' => '12 à 59 ans', 'price' => 16.0, 'shown' => true, 'details' => array(array('number' => 1, 'ageMin' => 12, 'ageMax' => 59))), array('name' => 'Enfant', 'longDescription' => 'De 4 ans à 11 ans', 'shortDescription' => '4 à 11 ans', 'price' => 8.0, 'shown' => true, 'details' => array(array('number' => 1, 'ageMin' => 4, 'ageMax' => 11))), array('name' => 'Senior', 'longDescription' => 'A partir de 60 ans', 'shortDescription' => 'Plus de 60 ans', 'price' => 12.0, 'shown' => true, 'details' => array(array('number' => 1, 'ageMin' => 60, 'ageMax' => 999))), array('name' => 'Réduit', 'longDescription' => 'A partir de 12 ans', 'shortDescription' => 'Plus de 12 ans', 'price' => 10.0, 'shown' => false, 'details' => array(array('number' => 1, 'ageMin' => 12, 'ageMax' => 999))), array('name' => 'Famille', 'longDescription' => 'Famille (2 adultes et 2 enfants de même nom de famille', 'shortDescription' => 'Famille: 2adu./2enf.', 'price' => 35.0, 'shown' => true, 'details' => array(array('number' => 1, 'ageMin' => 12, 'ageMax' => 999), array('number' => 2, 'ageMin' => 12, 'ageMax' => 999), array('number' => 3, 'ageMin' => 4, 'ageMax' => 11), array('number' => 4, 'ageMin' => 4, 'ageMax' => 11))));
     foreach ($ticketTypes as $type) {
         $ticketType = new TicketType();
         $ticketType->setName($type['name']);
         $ticketType->setLongDescription($type['longDescription']);
         $ticketType->setShortDescription($type['shortDescription']);
         $ticketType->setPrice($type['price']);
         $ticketType->setShown($type['shown']);
         $manager->persist($ticketType);
         foreach ($type['details'] as $detail) {
             $ticketTypeDetail = new TicketTypeDetail();
             $ticketTypeDetail->setNumber($detail['number']);
             $ticketTypeDetail->setAgeMin($detail['ageMin']);
             $ticketTypeDetail->setAgeMax($detail['ageMax']);
             $ticketType->addTicketTypeDetail($ticketTypeDetail);
         }
     }
     $manager->flush();
 }
Example #2
0
 /**
  * Add ticketTypeDetail
  *
  * @param \AppBundle\Entity\TicketTypeDetail $ticketTypeDetail
  *
  * @return TicketType
  */
 public function addTicketTypeDetail(\AppBundle\Entity\TicketTypeDetail $ticketTypeDetail)
 {
     $this->ticketTypeDetails[] = $ticketTypeDetail;
     $ticketTypeDetail->setTicketType($this);
     return $this;
 }