Ejemplo n.º 1
0
 public function checkin(CheckinCommand $command)
 {
     $updateCommand = new UpdateResourceCommand();
     $updateCommand->class = '\\BCRM\\BackendBundle\\Entity\\Event\\Ticket';
     $updateCommand->id = $command->ticket->getId();
     $updateCommand->data = array('checkedIn' => new \DateTime());
     $this->commandBus->handle($updateCommand);
     $event = new CheckedInEvent();
     $event->ticket = $command->ticket;
     $this->eventMessageBus->publish($event);
 }
Ejemplo n.º 2
0
 public function unregisterTicket(UnregisterTicketCommand $command)
 {
     // Create a new registration matching the unregistration
     $registration = $this->registrationRepo->getRegistrationForEmail($command->event, $command->unregistration->getEmail());
     if ($registration->isDefined()) {
         $r = $registration->get();
         $registrationData = array('event' => $command->event, 'email' => $command->unregistration->getEmail(), 'name' => $r->getName(), 'twitter' => $r->getTwitter(), 'arrival' => $r->getArrival(), 'food' => $r->getFood(), 'tags' => $r->getTags(), 'confirmed' => 1, 'saturday' => $r->getSaturday(), 'sunday' => $r->getSunday());
         if ($command->unregistration->getSaturday()) {
             $registrationData['saturday'] = false;
         }
         if ($command->unregistration->getSunday()) {
             $registrationData['sunday'] = false;
         }
         $createRegistrationCommand = new CreateResourceCommand();
         $createRegistrationCommand->class = '\\BCRM\\BackendBundle\\Entity\\Event\\Registration';
         $createRegistrationCommand->data = $registrationData;
         $this->commandBus->handle($createRegistrationCommand);
     }
     // Delete tickets
     foreach ($this->ticketRepo->getTicketsForEmail($command->event, $command->unregistration->getEmail()) as $ticket) {
         if ($ticket->isSaturday() && $command->unregistration->getSaturday() || $ticket->isSunday() && $command->unregistration->getSunday()) {
             $deleteTicketCommand = new DeleteResourceCommand();
             $deleteTicketCommand->class = '\\BCRM\\BackendBundle\\Entity\\Event\\Ticket';
             $deleteTicketCommand->id = $ticket->getId();
             $this->commandBus->handle($deleteTicketCommand);
             $event = new TicketDeletedEvent();
             $event->ticket = $ticket;
             $this->eventMessageBus->publish($event);
         }
     }
     // Mark unregistration as processed
     $updateCommand = new UpdateResourceCommand();
     $updateCommand->class = '\\BCRM\\BackendBundle\\Entity\\Event\\Unregistration';
     $updateCommand->id = $command->unregistration->getId();
     $updateCommand->data = array('processed' => true);
     $this->commandBus->handle($updateCommand);
 }