You are here

public function RegistrantsElementUtility::replaceFirstRegistrant in RNG - Events and Registrations 3.x

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

File

src/RegistrantsElementUtility.php, line 100

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);
}