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
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
$ci
protected
ContainerInterface
$ci
$displayErrorInfo
protected
bool
$displayErrorInfo
$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
mixedregister()
Register this class with the shutdown handler.
public
register(
)
: mixed
Return values
mixedfatalHandler()
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
mixedbuildErrorInfoMessage()
Build the error message string.
protected
buildErrorInfoMessage(
$error :
array
)
: string
Parameters
- $error : array
Return values
stringbuildErrorPage()
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
stringbuildHtmlErrorPage()
Build an HTML error page from an error string.
protected
buildHtmlErrorPage(
$message :
string
)
: string
Parameters
- $message : string
Return values
stringdetermineContentType()
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