class CustomPageExceptionHtmlSubscriber extends DefaultExceptionHtmlSubscriber (View source)

Exception subscriber for handling core custom HTML error pages.

Properties

protected HttpKernelInterface $httpKernel

The HTTP kernel.

from  DefaultExceptionHtmlSubscriber
protected LoggerInterface $logger

The logger instance.

from  DefaultExceptionHtmlSubscriber
protected RedirectDestinationInterface $redirectDestination

The redirect destination service.

from  DefaultExceptionHtmlSubscriber
protected UrlMatcherInterface $accessUnawareRouter

A router implementation which does not check access.

from  DefaultExceptionHtmlSubscriber
protected ConfigFactoryInterface $configFactory

The configuration factory.

protected AccessManagerInterface $accessManager

The access manager.

Methods

array
getHandledFormats()

Specifies the request formats this subscriber will respond to.

static int
getPriority()

Specifies the priority of all listeners in this class.

onException(ExceptionEvent $event)

Handles errors for this subscriber.

static array
getSubscribedEvents()

Registers the methods in this class that should be listeners.

__construct(ConfigFactoryInterface $config_factory, HttpKernelInterface $http_kernel, LoggerInterface $logger, RedirectDestinationInterface $redirect_destination, UrlMatcherInterface $access_unaware_router, AccessManagerInterface $access_manager)

Constructs a new CustomPageExceptionHtmlSubscriber.

on4xx(ExceptionEvent $event)

Handles a 4xx error for HTML.

on401(ExceptionEvent $event)

Handles a 401 error for HTML.

on403(ExceptionEvent $event)

Handles a 403 error for HTML.

on404(ExceptionEvent $event)

Handles a 404 error for HTML.

makeSubrequest(ExceptionEvent $event, string $url, int $status_code)

Makes a subrequest to retrieve the default error page.

makeSubrequestToCustomPath(ExceptionEvent $event, string $custom_path, int $status_code)

Makes a subrequest to retrieve the custom error page.

Details

protected array getHandledFormats()

Specifies the request formats this subscriber will respond to.

Return Value

array

An indexed array of the format machine names that this subscriber will attempt to process, such as "html" or "json". Returning an empty array will apply to all formats.

static protected int getPriority()

Specifies the priority of all listeners in this class.

The default priority is 1, which is very low. To have listeners that have a "first attempt" at handling exceptions return a higher priority.

Return Value

int

The event priority of this subscriber.

onException(ExceptionEvent $event)

Handles errors for this subscriber.

Parameters

ExceptionEvent $event

The event to process.

static array getSubscribedEvents()

Registers the methods in this class that should be listeners.

Return Value

array

An array of event listener definitions.

__construct(ConfigFactoryInterface $config_factory, HttpKernelInterface $http_kernel, LoggerInterface $logger, RedirectDestinationInterface $redirect_destination, UrlMatcherInterface $access_unaware_router, AccessManagerInterface $access_manager)

Constructs a new CustomPageExceptionHtmlSubscriber.

Parameters

ConfigFactoryInterface $config_factory

The configuration factory.

HttpKernelInterface $http_kernel

The HTTP kernel.

LoggerInterface $logger

The logger service.

RedirectDestinationInterface $redirect_destination

The redirect destination service.

UrlMatcherInterface $access_unaware_router

A router implementation which does not check access.

AccessManagerInterface $access_manager

The access manager.

on4xx(ExceptionEvent $event)

Handles a 4xx error for HTML.

Parameters

ExceptionEvent $event

The event to process.

on401(ExceptionEvent $event)

Handles a 401 error for HTML.

Parameters

ExceptionEvent $event

The event to process.

on403(ExceptionEvent $event)

Handles a 403 error for HTML.

Parameters

ExceptionEvent $event

The event to process.

on404(ExceptionEvent $event)

Handles a 404 error for HTML.

Parameters

ExceptionEvent $event

The event to process.

protected makeSubrequest(ExceptionEvent $event, string $url, int $status_code)

Makes a subrequest to retrieve the default error page.

Parameters

ExceptionEvent $event

The event to process.

string $url

The path/url to which to make a subrequest for this error message.

int $status_code

The status code for the error being handled.

protected makeSubrequestToCustomPath(ExceptionEvent $event, string $custom_path, int $status_code)

Makes a subrequest to retrieve the custom error page.

Parameters

ExceptionEvent $event

The event to process.

string $custom_path

The custom path to which to make a subrequest for this error message.

int $status_code

The status code for the error being handled.