public function Registration::setRegistrantQty in RNG - Events and Registrations 8.2
Same name and namespace in other branches
- 3.x src/Entity/Registration.php \Drupal\rng\Entity\Registration::setRegistrantQty()
@inheritDoc
Overrides RegistrationInterface::setRegistrantQty
File
- src/
Entity/ Registration.php, line 486
Class
- Registration
- Defines the registration entity class.
Namespace
Drupal\rng\EntityCode
public function setRegistrantQty($qty) {
$registrants = $this
->getRegistrantIds();
if ($qty > 0) {
if (count($registrants) > $qty) {
throw new MaxRegistrantsExceededException('Cannot set registrant qty below number of current registrants.');
}
$event_meta = $this
->getEventMeta();
$max = $event_meta
->getRegistrantsMaximum();
if (!empty($max) && $max > -1 && $qty > $max) {
throw new MaxRegistrantsExceededException('Cannot set registrations above event maximum');
}
}
$this
->set('registrant_qty', $qty);
return $this;
}