GetResponseForExceptionEvent
extends GetResponseEvent
in package
Allows to create a response for a thrown exception.
Call setResponse() to set the response that will be returned for the current request. The propagation of this event is stopped as soon as a response is set.
You can also call setException() to replace the thrown exception. This exception will be thrown if no response is set during processing of this event.
Tags
Table of Contents
- $allowCustomResponseCode : bool
- $exception : Exception
- The exception object.
- $kernel : mixed
- $propagationStopped : bool
- $request : mixed
- $requestType : mixed
- $response : mixed
- __construct() : mixed
- allowCustomResponseCode() : mixed
- Mark the event as allowing a custom response code.
- getException() : Exception
- Returns the thrown exception.
- getKernel() : HttpKernelInterface
- Returns the kernel in which this event was thrown.
- getRequest() : Request
- Returns the request the kernel is currently processing.
- getRequestType() : int
- Returns the request type the kernel is currently processing.
- getResponse() : Response|null
- Returns the response object.
- hasResponse() : bool
- Returns whether a response was set.
- isAllowingCustomResponseCode() : bool
- Returns true if the event allows a custom response code.
- isMasterRequest() : bool
- Checks if this is a master request.
- isPropagationStopped() : bool
- Returns whether further event listeners should be triggered.
- setException() : mixed
- Replaces the thrown exception.
- setResponse() : mixed
- Sets a response and stops event propagation.
- stopPropagation() : mixed
- Stops the propagation of the event to further event listeners.
Properties
$allowCustomResponseCode
private
bool
$allowCustomResponseCode
= false
$exception
The exception object.
private
Exception
$exception
$kernel
private
mixed
$kernel
$propagationStopped
private
bool
$propagationStopped
= false
Whether no further event listeners should be triggered
$request
private
mixed
$request
$requestType
private
mixed
$requestType
$response
private
mixed
$response
Methods
__construct()
public
__construct(HttpKernelInterface $kernel, Request $request, mixed $requestType, Exception $e) : mixed
Parameters
- $kernel : HttpKernelInterface
- $request : Request
- $requestType : mixed
- $e : Exception
Return values
mixed —allowCustomResponseCode()
Mark the event as allowing a custom response code.
public
allowCustomResponseCode() : mixed
Return values
mixed —getException()
Returns the thrown exception.
public
getException() : Exception
Return values
Exception —The thrown exception
getKernel()
Returns the kernel in which this event was thrown.
public
getKernel() : HttpKernelInterface
Return values
HttpKernelInterface —getRequest()
Returns the request the kernel is currently processing.
public
getRequest() : Request
Return values
Request —getRequestType()
Returns the request type the kernel is currently processing.
public
getRequestType() : int
Return values
int —One of HttpKernelInterface::MASTER_REQUEST and HttpKernelInterface::SUB_REQUEST
getResponse()
Returns the response object.
public
getResponse() : Response|null
Return values
Response|null —hasResponse()
Returns whether a response was set.
public
hasResponse() : bool
Return values
bool —Whether a response was set
isAllowingCustomResponseCode()
Returns true if the event allows a custom response code.
public
isAllowingCustomResponseCode() : bool
Return values
bool —isMasterRequest()
Checks if this is a master request.
public
isMasterRequest() : bool
Return values
bool —True if the request is a master request
isPropagationStopped()
Returns whether further event listeners should be triggered.
public
isPropagationStopped() : bool
Tags
Return values
bool —Whether propagation was already stopped for this event
setException()
Replaces the thrown exception.
public
setException(Exception $exception) : mixed
This exception will be thrown if no response is set in the event.
Parameters
- $exception : Exception
-
The thrown exception
Return values
mixed —setResponse()
Sets a response and stops event propagation.
public
setResponse(Response $response) : mixed
Parameters
- $response : Response
Return values
mixed —stopPropagation()
Stops the propagation of the event to further event listeners.
public
stopPropagation() : mixed
If multiple event listeners are connected to the same event, no further event listener will be triggered once any trigger calls stopPropagation().