コード例 #1
0
ファイル: EventController.php プロジェクト: Ravetracer/www
 /**
  * @param Request $request
  * @param         $id
  * @param         $code
  *
  * @return array|RedirectResponse
  * @Template()
  */
 public function cancelTicketAction(Request $request, $id, $code)
 {
     /* @var $ticket Ticket */
     $ticket = $this->ticketRepo->getTicketByIdAndCode($id, $code)->getOrThrow(new NotFoundHttpException('Unknown ticket.'));
     if ($request->isMethod('POST')) {
         $command = new UnregisterCommand();
         $command->event = $this->eventRepo->getNextEvent()->getOrThrow(new AccessDeniedHttpException('No event.'));
         $command->email = $ticket->getEmail();
         $command->saturday = $ticket->isSaturday();
         $command->sunday = $ticket->isSunday();
         $command->confirmed = true;
         $this->commandBus->handle($command);
         return new RedirectResponse($this->router->generate('bcrmweb_unregistration_confirmed'));
     }
     return array('ticket' => $ticket, 'sponsors' => $this->reader->getPage('Sponsoren/Index.md'));
 }
コード例 #2
0
ファイル: Event.php プロジェクト: Ravetracer/www
 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);
 }