You are here

protected function Registration::createStubs in RNG - Events and Registrations 3.x

Same name and namespace in other branches
  1. 8.2 src/Entity/Registration.php \Drupal\rng\Entity\Registration::createStubs()
2 calls to Registration::createStubs()
Registration::getRegistrants in src/Entity/Registration.php
Get registrants for the registration.
Registration::postSave in src/Entity/Registration.php
Acts on a saved entity before the insert or update hook is invoked.

File

src/Entity/Registration.php, line 436

Class

Registration
Defines the registration entity class.

Namespace

Drupal\rng\Entity

Code

protected function createStubs() {
  $stub_count = $this
    ->getRegistrantQty();
  if ($stub_count && $this
    ->canAddRegistrants()) {

    /** @var \Drupal\rng\RegistrantFactoryInterface $registrant_factory */
    $registrant_factory = \Drupal::service('rng.registrant.factory');
    $registrant_count = count($this
      ->getRegistrantIds());
    $stub_count -= $registrant_count;
    while ($stub_count) {
      $registrant = $registrant_factory
        ->createRegistrant([
        'event' => $this
          ->getEvent(),
      ]);
      $registrant
        ->setRegistration($this)
        ->save();
      $stub_count--;
    }
  }
}