Exemplo n.º 1
0
 /**
  * Event initialization
  *
  * This is a workaround to stay bundle independent from fixtures, or cli init
  * Feel free to remove this call after init or switch to the fixtures
  */
 protected function initEvent()
 {
     $locales = $this->container->getParameter('event.locales');
     $event = $this->getRepository('EventEventBundle:Event')->getEvent();
     $now = new \DateTime();
     if (!$event) {
         $event = new Event();
         $event->setTitle('My Event')->setDescription('My another awesome event!')->setStartDate($now)->setEndDate($now->modify('+1 day'))->setVenue('Burj Khalifa Tower')->setEmail('*****@*****.**');
         $speaker = new Speaker();
         $speaker->setFirstName('Phill')->setLastName('Pilow')->setCompany('Reseach Supplier');
         if ($locales) {
             foreach ($locales as $locale => $title) {
                 $eventTranslation = new EventTranslation();
                 $eventTranslation->setEvent($event);
                 $eventTranslation->setlocale($locale);
                 $this->getManager()->persist($eventTranslation);
                 $speakerTranslation = new SpeakerTranslation();
                 $speakerTranslation->setSpeaker($speaker);
                 $speakerTranslation->setlocale($locale);
                 $this->getManager()->persist($speakerTranslation);
             }
         }
         $this->getManager()->persist($event);
         $this->getManager()->persist($speaker);
         $this->getManager()->flush();
     }
 }
Exemplo n.º 2
0
 /**
  * Add event
  *
  * @param Event $event
  */
 public function addEvent(Event $event)
 {
     $event->addSpeaker($this);
     $this->events[] = $event;
 }