class EnforcedResponseException

Same name in other branches
  1. 9 core/lib/Drupal/Core/Form/EnforcedResponseException.php \Drupal\Core\Form\EnforcedResponseException
  2. 10 core/lib/Drupal/Core/Form/EnforcedResponseException.php \Drupal\Core\Form\EnforcedResponseException
  3. 11.x core/lib/Drupal/Core/Form/EnforcedResponseException.php \Drupal\Core\Form\EnforcedResponseException

Custom exception to break out of the main request and enforce a response.

Hierarchy

Expanded class hierarchy of EnforcedResponseException

6 files declare their use of EnforcedResponseException
authorize.php in core/authorize.php
Administrative script for running authorized file operations.
BigPipeResponseAttachmentsProcessor.php in core/modules/big_pipe/src/Render/BigPipeResponseAttachmentsProcessor.php
FieldBlock.php in core/modules/layout_builder/src/Plugin/Block/FieldBlock.php
FieldBlockTest.php in core/modules/layout_builder/tests/src/Kernel/FieldBlockTest.php
FormBuilderTest.php in core/tests/Drupal/Tests/Core/Form/FormBuilderTest.php
Contains \Drupal\Tests\Core\Form\FormBuilderTest.

... See full list

File

core/lib/Drupal/Core/Form/EnforcedResponseException.php, line 10

Namespace

Drupal\Core\Form
View source
class EnforcedResponseException extends \Exception {
    
    /**
     * The response to be enforced.
     *
     * @var \Symfony\Component\HttpFoundation\Response
     */
    protected $response;
    
    /**
     * Constructs a new enforced response exception.
     *
     * @param \Symfony\Component\HttpFoundation\Response $response
     *   The response to be enforced.
     * @param string $message
     *   (optional) The exception message.
     * @param int $code
     *   (optional) A user defined exception code.
     * @param \Exception $previous
     *   (optional) The previous exception for nested exceptions
     */
    public function __construct(Response $response, $message = "", $code = 0, \Exception $previous = NULL) {
        parent::__construct($message, $code, $previous);
        $this->response = $response;
    }
    
    /**
     * Return the response to be enforced.
     *
     * @returns \Symfony\Component\HttpFoundation\Response $response
     *   The response to be enforced.
     */
    public function getResponse() {
        return $this->response;
    }

}

Members

Title Sort descending Modifiers Object type Summary
EnforcedResponseException::$response protected property The response to be enforced.
EnforcedResponseException::getResponse public function Return the response to be enforced.
EnforcedResponseException::__construct public function Constructs a new enforced response exception.

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