class RegistrationWaitListSubscriber in RNG - Events and Registrations 3.x
Same name and namespace in other branches
- 8.2 src/EventSubscriber/RegistrationWaitlistSubscriber.php \Drupal\rng\EventSubscriber\RegistrationWaitListSubscriber
Class RegistrationWaitListSubscriber.
Hierarchy
- class \Drupal\rng\EventSubscriber\RegistrationWaitListSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface uses MessengerTrait, StringTranslationTrait
Expanded class hierarchy of RegistrationWaitListSubscriber
1 string reference to 'RegistrationWaitListSubscriber'
1 service uses RegistrationWaitListSubscriber
File
- src/
EventSubscriber/ RegistrationWaitListSubscriber.php, line 15
Namespace
Drupal\rng\EventSubscriberView source
class RegistrationWaitListSubscriber implements EventSubscriberInterface {
use StringTranslationTrait;
use MessengerTrait;
/**
* Drupal\rng\EventManagerInterface definition.
*
* @var \Drupal\rng\EventManagerInterface
*/
protected $rngEventManager;
/**
* RegistrationWaitListSubscriber constructor.
*
* @param \Drupal\rng\EventManagerInterface $rng_event_manager
* The event manager.
* @param \Drupal\Core\Messenger\MessengerInterface $messenger
* The messenger service.
*/
public function __construct(EventManagerInterface $rng_event_manager) {
$this->rngEventManager = $rng_event_manager;
}
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
$events[RegistrationEvents::REGISTRATION_INSERT] = [
'onRegistrationInsert',
-1,
];
return $events;
}
/**
* Notify the user if they are added to a wait list.
*
* @param \Drupal\rng\Event\RegistrationEvent $event
* The event.
*
* @throws \Drupal\rng\Exception\InvalidEventException
*/
public function onRegistrationInsert(RegistrationEvent $event) {
$meta = $this->rngEventManager
->getMeta($event
->getRegistration()
->getEvent());
if ($meta
->allowWaitList() && $meta
->getCapacity() - $meta
->countRegistrations() < 0) {
$this
->messenger()
->addStatus($this
->t('Registration is at its capacity. You have been added to a waiting list.'));
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
MessengerTrait:: |
protected | property | The messenger. | 27 |
MessengerTrait:: |
public | function | Gets the messenger. | 27 |
MessengerTrait:: |
public | function | Sets the messenger. | |
RegistrationWaitListSubscriber:: |
protected | property | Drupal\rng\EventManagerInterface definition. | |
RegistrationWaitListSubscriber:: |
public static | function | ||
RegistrationWaitListSubscriber:: |
public | function | Notify the user if they are added to a wait list. | |
RegistrationWaitListSubscriber:: |
public | function | RegistrationWaitListSubscriber constructor. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 4 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |