You are here

public static function Registrants::submitMyself in RNG - Events and Registrations 3.x

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

Submission callback for referencing the current user.

Parameters

array $form: The complete form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

File

src/Element/Registrants.php, line 937

Class

Registrants
Provides a form element for a registrant and person association.

Namespace

Drupal\rng\Element

Code

public static function submitMyself(array $form, FormStateInterface $form_state) {
  $form_state
    ->setRebuild();
  $element = RegistrantsElement::findElement($form, $form_state);
  $utility = new RegistrantsElement($element, $form_state);
  $registrant = $utility
    ->buildRegistrant();
  $utility
    ->clearPeopleFormInput();
  $current_user = \Drupal::currentUser();
  if ($current_user
    ->isAuthenticated()) {
    $person = User::load($current_user
      ->id());
    $registrant
      ->setIdentity($person);
  }
}