/**
  * Returns an array with the amount of possible simultaneous registrations
  * respecting the maxRegistrationsPerUser setting and also respects the amount
  * of remaining free places.
  *
  * The returned array index starts at 1 if at least one registration is possible
  *
  * @param \DERHANSEN\SfEventMgt\Domain\Model\Event $event Event
  *
  * @return array
  */
 public function render($event)
 {
     $minPossibleRegistrations = 1;
     if ($event->getMaxParticipants() > 0 && $event->getMaxRegistrationsPerUser() >= $event->getFreePlaces() && !$event->getEnableWaitlist()) {
         $maxPossibleRegistrations = $event->getFreePlaces();
     } else {
         $maxPossibleRegistrations = $event->getMaxRegistrationsPerUser();
     }
     $result = [$maxPossibleRegistrations];
     if ($maxPossibleRegistrations >= $minPossibleRegistrations) {
         $arrayWithZeroAsIndex = range($minPossibleRegistrations, $maxPossibleRegistrations);
         $result = array_combine(range(1, count($arrayWithZeroAsIndex)), $arrayWithZeroAsIndex);
     }
     return $result;
 }
Example #2
0
 /**
  * @test
  */
 public function getEnableWaitlistReturnsInitialValueForBoolean()
 {
     $this->assertSame(false, $this->subject->getEnableWaitlist());
 }
 /**
  * Returns if the given amount of registrations for the event will be registrations for the waitlist
  * (depending on the total amount of registrations and free places)
  *
  * @param \DERHANSEN\SfEventMgt\Domain\Model\Event $event
  * @param int $amountOfRegistrations
  * @return bool
  */
 public function isWaitlistRegistration($event, $amountOfRegistrations)
 {
     if ($event->getMaxParticipants() === 0 || !$event->getEnableWaitlist()) {
         return false;
     }
     $result = false;
     if ($event->getFreePlaces() > 0 && $event->getFreePlaces() < $amountOfRegistrations) {
         $result = true;
     } elseif ($event->getFreePlaces() <= 0) {
         $result = true;
     }
     return $result;
 }