function ContactForm::getRedirectUrl

Same name and namespace in other branches
  1. 9 core/modules/contact/src/Entity/ContactForm.php \Drupal\contact\Entity\ContactForm::getRedirectUrl()
  2. 8.9.x core/modules/contact/src/Entity/ContactForm.php \Drupal\contact\Entity\ContactForm::getRedirectUrl()
  3. 11.x core/modules/contact/src/Entity/ContactForm.php \Drupal\contact\Entity\ContactForm::getRedirectUrl()

Returns the \Drupal\Core\Url object for redirect path.

Empty redirect property results a \Drupal\Core\Url object of front page.

Return value

\Drupal\Core\Url The redirect \Drupal\Core\Url object.

Overrides ContactFormInterface::getRedirectUrl

File

core/modules/contact/src/Entity/ContactForm.php, line 150

Class

ContactForm
Defines the contact form entity.

Namespace

Drupal\contact\Entity

Code

public function getRedirectUrl() {
  if ($this->redirect) {
    $url = Url::fromUserInput($this->redirect);
  }
  else {
    $url = Url::fromRoute('<front>');
  }
  return $url;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.