You are here

public function Registration::getRegistrants in RNG - Events and Registrations 8.2

Same name and namespace in other branches
  1. 8 src/Entity/Registration.php \Drupal\rng\Entity\Registration::getRegistrants()
  2. 3.x src/Entity/Registration.php \Drupal\rng\Entity\Registration::getRegistrants()

Get registrants for the registration.

Return value

\Drupal\rng\Entity\RegistrantInterface[] An array of registrant entities.

Overrides RegistrationInterface::getRegistrants

1 call to Registration::getRegistrants()
Registration::hasIdentity in src/Entity/Registration.php
Searches registrants on this registration for an identity.

File

src/Entity/Registration.php, line 197

Class

Registration
Defines the registration entity class.

Namespace

Drupal\rng\Entity

Code

public function getRegistrants() {
  if ($this
    ->getRegistrantQty()) {
    $this
      ->createStubs();
  }
  $registrants = \Drupal::entityTypeManager()
    ->getStorage('registrant')
    ->loadMultiple($this
    ->getRegistrantIds());
  if (!count($registrants)) {

    /** @var \Drupal\rng\RegistrantFactoryInterface $registrant_factory */
    $registrant_factory = \Drupal::service('rng.registrant.factory');

    // Always return at least one, even if it's not saved. This should only
    // run if there is not a defined number of registrants for this
    // registration, and no existing registrants.
    $registrant = $registrant_factory
      ->createRegistrant([
      'event' => $this
        ->getEvent(),
    ]);
    $registrant
      ->setRegistration($this);
    $registrants[] = $registrant;
  }
  return $registrants;
}