You are here

public function RegistrantsElementUtility::replaceFirstRegistrant in RNG - Events and Registrations 8

Same name and namespace in other branches
  1. 8.2 src/RegistrantsElementUtility.php \Drupal\rng\RegistrantsElementUtility::replaceFirstRegistrant()
  2. 3.x src/RegistrantsElementUtility.php \Drupal\rng\RegistrantsElementUtility::replaceFirstRegistrant()

File

src/RegistrantsElementUtility.php, line 89

Class

RegistrantsElementUtility

Namespace

Drupal\rng

Code

public function replaceFirstRegistrant(RegistrantInterface $registrant) {
  $registrants = $this
    ->getRegistrants();

  // Get first key, or use 0 if there is none.
  $key = key($registrants);
  $key = $key !== NULL ? $key : 0;
  $registrants[$key] = $registrant;
  $this
    ->setRegistrants($registrants);
}