You are here

public function EventMeta::remainingRegistrantCapacity in RNG - Events and Registrations 3.x

Same name and namespace in other branches
  1. 8.2 src/EventMeta.php \Drupal\rng\EventMeta::remainingRegistrantCapacity()

Calculates how many more registrants can be added to this event.

This value will not be negative if there are excessive registrations.

Return value

int|EventMetaInterfaceCAPACITY_UNLIMITED Number of new registrants allowed (>= 0), or unlimited.

Overrides EventMetaInterface::remainingRegistrantCapacity

File

src/EventMeta.php, line 247

Class

EventMeta
Meta event wrapper for RNG.

Namespace

Drupal\rng

Code

public function remainingRegistrantCapacity() {
  $capacity = $this
    ->getRegistrantCapacity();
  if ($capacity == EventMetaInterface::CAPACITY_UNLIMITED) {
    return $capacity;
  }
  $remaining = $capacity - $this
    ->countRegistrants();
  return $remaining > 0 ? $remaining : 0;
}