You are here

protected function ContactEmailForm::getContactForm in Contact Emails 8

Get the contact form from the current request.

Parameters

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

Return value

\Drupal\contact\ContactFormInterface The contact form.

1 call to ContactEmailForm::getContactForm()
ContactEmailForm::form in src/Form/ContactEmailForm.php
Gets the actual form array to be built.

File

src/Form/ContactEmailForm.php, line 273

Class

ContactEmailForm
Defines the tax service add/edit form.

Namespace

Drupal\contact_emails\Form

Code

protected function getContactForm(FormStateInterface $form_state) {

  /** @var \Drupal\contact_emails\Entity\ContactEmailInterface $entity */
  $entity = $this->entity;
  if (!$entity
    ->get('contact_form')
    ->isEmpty()) {
    $contactForm = $entity
      ->get('contact_form')->target_id;
  }
  if (empty($contactForm) && $form_state
    ->hasValue('contact_form')) {
    $value = $form_state
      ->getValue('contact_form', NULL);
    $contactForm = is_array($value) ? $value[0]['target_id'] : NULL;
  }

  /** @var \Drupal\contact\ContactFormInterface $contactForm */
  if (empty($contactForm)) {
    $contactForm = \Drupal::routeMatch()
      ->getParameter('contact_form');
  }
  if (is_string($contactForm)) {
    $contactForm = ContactForm::load($contactForm);
  }
  return $contactForm;
}