You are here

public function EventMeta::remainingCapacity in RNG - Events and Registrations 8

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

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

Return value

integer|EventMetaInterface::CAPACITY_UNLIMITED Number of new registrations allowed (>= 0), or unlimited.

Overrides EventMetaInterface::remainingCapacity

File

src/EventMeta.php, line 211

Class

EventMeta
Meta event wrapper for RNG.

Namespace

Drupal\rng

Code

public function remainingCapacity() {
  $capacity = $this
    ->getCapacity();
  if ($capacity == EventMetaInterface::CAPACITY_UNLIMITED) {
    return $capacity;
  }
  $remaining = $capacity - $this
    ->countRegistrations();
  return $remaining > 0 ? $remaining : 0;
}