UserFrosting API

ShutdownHandler Uses DeterminesContentType

Registers a handler to be invoked whenever the application shuts down.

If it shut down due to a fatal error, will generate a clean error message.

Tags
author

Alex Weissman (https://alexanderweissman.com)

Table of Contents

$ci ContainerInterface
$displayErrorInfo bool
$knownContentTypes Known handled content types. array
__construct() Constructor. mixed
register() Register this class with the shutdown handler. mixed
fatalHandler() Set up the fatal error handler, so that we get a clean error message and alert instead of a WSOD. mixed
buildErrorInfoMessage() Build the error message string. string
buildErrorPage() Build an error response of the appropriate type as determined by the request's Accept header. string
buildHtmlErrorPage() Build an HTML error page from an error string. string
determineContentType() Determine which content type we know about is wanted using Accept header. string

Properties

$knownContentTypes

Known handled content types.

protected array $knownContentTypes = ['application/json', 'application/xml', 'text/xml', 'text/html', 'text/plain']

Methods

__construct()

Constructor.

public __construct( $ci : ContainerInterface , $displayErrorInfo : bool ) : mixed
Parameters
$ci : ContainerInterface

The global container object, which holds all your services.

$displayErrorInfo : bool
Return values
mixed

register()

Register this class with the shutdown handler.

public register( ) : mixed
Return values
mixed

fatalHandler()

Set up the fatal error handler, so that we get a clean error message and alert instead of a WSOD.

public fatalHandler( ) : mixed
Return values
mixed

buildErrorInfoMessage()

Build the error message string.

protected buildErrorInfoMessage( $error : array ) : string
Parameters
$error : array
Return values
string

buildErrorPage()

Build an error response of the appropriate type as determined by the request's Accept header.

protected buildErrorPage( $message : string ) : string
Parameters
$message : string
Return values
string

buildHtmlErrorPage()

Build an HTML error page from an error string.

protected buildHtmlErrorPage( $message : string ) : string
Parameters
$message : string
Return values
string

determineContentType()

Determine which content type we know about is wanted using Accept header.

protected determineContentType( $request : ServerRequestInterface [, $ajaxDebug : bool = false ] ) : string

Note: This method is a bare-bones implementation designed specifically for Slim's error handling requirements. Consider a fully-feature solution such as willdurand/negotiation for any other situation.

Parameters
$request : ServerRequestInterface
$ajaxDebug : bool = false
Return values
string

Search results