You are here

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

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

Load first registrant into form inputs.

File

src/RegistrantsElementUtility.php, line 271

Class

RegistrantsElementUtility

Namespace

Drupal\rng

Code

public function setForBundleAsFirstRegistrant() {

  /** @var \Drupal\rng\RegistrantInterface[] $registrants */
  $registrants = $this->element['#value'];
  $registrant = reset($registrants);
  if ($registrant) {
    $identity = $registrant
      ->getIdentity();
    $entity_type = $identity
      ->getEntityTypeId();
    $bundle = $identity
      ->bundle();
    $new_value = "{$entity_type}:{$bundle}";
    $for_bundle_tree = array_merge($this->element['#parents'], [
      'entities',
      'for_bundle',
    ]);
    NestedArray::setValue($this->formState
      ->getUserInput(), $for_bundle_tree, $new_value);
  }
}