/** * @param CreateEventCommand $command */ public function handle(CreateEventCommand $command) { $dojo = $this->doctrine->getRepository('CoderDojoWebsiteBundle:Dojo')->find($command->getDojoId()); $event = new DojoEvent(); $event->setName($command->getName()); $event->setDate($command->getDate()); $event->setType($command->getType()); $event->setZenId($command->getZenId()); $event->setUrl($command->getUrl()); $event->setDojo($dojo); $dojo->addEvent($event); $this->doctrine->persist($event); $this->doctrine->flush(); $event = new EventCreatedEvent($command->getDojoId(), $command->getName(), $command->getDate(), $command->getUrl(), $command->getZenId(), $command->getType()); $this->eventRecorder->record($event); }