function EnforcedResponse::createFromException
Same name in other branches
- 8.9.x core/lib/Drupal/Core/Form/EnforcedResponse.php \Drupal\Core\Form\EnforcedResponse::createFromException()
- 10 core/lib/Drupal/Core/Form/EnforcedResponse.php \Drupal\Core\Form\EnforcedResponse::createFromException()
- 11.x core/lib/Drupal/Core/Form/EnforcedResponse.php \Drupal\Core\Form\EnforcedResponse::createFromException()
Constructs a new enforced response from the given exception.
Note that it is necessary to traverse the exception chain when searching for an enforced response. Otherwise it would be impossible to find an exception thrown from within a twig template.
Parameters
\Throwable $e: The exception where the enforced response is to be extracted from.
Return value
static|null The enforced response or NULL if the exception chain does not contain a \Drupal\Core\Form\EnforcedResponseException exception.
1 call to EnforcedResponse::createFromException()
- EnforcedFormResponseSubscriber::onKernelException in core/
lib/ Drupal/ Core/ EventSubscriber/ EnforcedFormResponseSubscriber.php - Replaces the response in case an EnforcedResponseException was thrown.
File
-
core/
lib/ Drupal/ Core/ Form/ EnforcedResponse.php, line 44
Class
- EnforcedResponse
- A wrapper containing a response which is to be enforced upon delivery.
Namespace
Drupal\Core\FormCode
public static function createFromException(\Throwable $e) {
while ($e) {
if ($e instanceof EnforcedResponseException) {
return new static($e->getResponse());
}
$e = $e->getPrevious();
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.