/**
  *
  */
 public function statusAction()
 {
     $registrationResource = NULL;
     if (NULL !== ($account = $this->securityContext->getAccount())) {
         $registration = $this->registrationRepository->findOneByAccountAndNotCompleted($account);
         if ($registration !== NULL) {
             $registrationResource = $this->dataTransferObjectFactory->getDataTransferObject($registration)->getResource();
         }
     }
     $this->view->assign('value', array('tickets' => $this->bookableService->getTicketsStatus(), 'rooms' => $this->bookableService->getRoomStatus(), 'registrationResource' => $registrationResource));
 }
 /**
  * Move tickets and rooms from the waiting list
  * to pending if there are free quota
  */
 public function updateWaitingListCommand()
 {
     $registrationsToNotify = [];
     $numberOfTickets = $this->bookableService->getTicketsStatus();
     if ($numberOfTickets > 0) {
         $waitingTickets = $this->ticketRepository->findWaitingByCount($numberOfTickets);
         /** @var Ticket $ticket */
         foreach ($waitingTickets as $ticket) {
             $priorBookingState = $ticket->getBookingState();
             $ticket->setBookingState(AbstractBookable::BOOKING_STATE_PENDING);
             $this->ticketRepository->update($ticket);
             /** @var Participant $participant */
             $participant = $this->registrationParticipantRepository->findOneByTicket($ticket);
             /** @var Registration $notification */
             $notification = $participant->getRegistration();
             $registrationIdentifier = $this->persistenceManager->getIdentifierByObject($notification);
             if (!array_key_exists($registrationIdentifier, $registrationsToNotify)) {
                 $registrationsToNotify[$registrationIdentifier] = ['registration' => $notification, 'ticketBookingStateChanged' => [], 'roomBookingStateChanged' => []];
             }
             $participantIdentifier = $this->persistenceManager->getIdentifierByObject($participant);
             $registrationsToNotify[$registrationIdentifier]['ticketBookingStateChanged'][$participantIdentifier] = ['participant' => $participant, 'priorBookingState' => $priorBookingState, 'newBookingState' => $ticket->getBookingState()];
         }
     }
     $numberOfRooms = $this->bookableService->getTicketsStatus();
     if ($numberOfRooms > 0) {
         $waitingRooms = $this->roomRepository->findWaitingByCount($numberOfRooms);
         /** @var Room $room */
         foreach ($waitingRooms as $room) {
             $priorBookingState = $room->getBookingState();
             $room->setBookingState(AbstractBookable::BOOKING_STATE_PENDING);
             $this->roomRepository->update($room);
             /** @var Participant $participant */
             $participant = $this->registrationParticipantRepository->findOneByRoom($room);
             /** @var Registration $registration */
             $notification = $participant->getRegistration();
             $registrationIdentifier = $this->persistenceManager->getIdentifierByObject($notification);
             if (!array_key_exists($registrationIdentifier, $registrationsToNotify)) {
                 $registrationsToNotify[$registrationIdentifier] = ['registration' => $notification, 'ticketBookingStateChanged' => [], 'roomBookingStateChanged' => []];
             }
             $participantIdentifier = $this->persistenceManager->getIdentifierByObject($participant);
             $registrationsToNotify[$registrationIdentifier]['roomBookingStateChanged'][$participantIdentifier] = ['participant' => $participant, 'priorBookingState' => $priorBookingState, 'newBookingState' => $room->getBookingState()];
         }
     }
     $this->persistenceManager->persistAll();
     /** @var array $notification */
     foreach ($registrationsToNotify as $notification) {
         $this->mailService->sendMoveToWaitingListMail($notification);
     }
 }
 /**
  * @test
  */
 public function ticketsAndRoomShouldBeUnavailable()
 {
     $this->inject($this->bookableService, 'configuration', [BookableService::TYPE_ROOM => ['fractionBase' => 12, 'availableQuota' => 10], BookableService::TYPE_TICKET => ['availableQuota' => 10]]);
     $bookables = $this->buildBookableRequest(10);
     $this->bookableService->requestRooms($bookables);
     $this->bookableService->requestTickets($bookables);
     $this->persistenceManager->persistAll();
     $this->assertEquals(0, $this->bookableService->getTicketsStatus());
     $this->assertEquals(0, $this->bookableService->getRoomStatus());
 }