class EnforcedResponseException

Same name in other branches
  1. 9 core/lib/Drupal/Core/Form/EnforcedResponseException.php \Drupal\Core\Form\EnforcedResponseException
  2. 8.9.x core/lib/Drupal/Core/Form/EnforcedResponseException.php \Drupal\Core\Form\EnforcedResponseException
  3. 10 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

8 files declare their use of EnforcedResponseException
authorize.php in core/authorize.php
Administrative script for running authorized file operations.
BigPipe.php in core/modules/big_pipe/src/Render/BigPipe.php
BigPipeResponseAttachmentsProcessor.php in core/modules/big_pipe/src/Render/BigPipeResponseAttachmentsProcessor.php
BigPipeTestController.php in core/modules/big_pipe/tests/modules/big_pipe_test/src/BigPipeTestController.php
FieldBlock.php in core/modules/layout_builder/src/Plugin/Block/FieldBlock.php

... 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.
     *
     * @return \Symfony\Component\HttpFoundation\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.