class ErrorPage extends Page (View source)

ErrorPage holds the content for the page of an error response.

Renders the page on each publish action into a static HTML file within the assets directory, after the naming convention /assets/error-.html. This enables us to show errors even if PHP experiences a recoverable error. ErrorPages

Properties

int $ErrorCode

HTTP Error code

Methods

public
bool
canAddChildren($member = null)

No description

public static 
response_for(int $statusCode, string|null $errorMessage = null)

Get a HTTPResponse to response to a HTTP error code if an ErrorPage for that code is present. First tries to serve it through the standard SilverStripe request method. Falls back to a static file generated when the user hit's save and publish in the CMS

public
requireDefaultRecords()

Ensures that there is always a 404 page by checking if there's an instance of ErrorPage with a 404 and 500 error code. If there is not, one is created when the DB is built.

protected
requireDefaultRecordFixture(array $defaultData)

Build default record from specification fixture

protected
array
getDefaultRecords()

Returns an array of arrays, each of which defines properties for a new ErrorPage record.

public
getCMSFields()

No description

public
bool
publishSingle()

When an error page is published, create a static HTML page with its content, so the page can be shown even when SilverStripe is not functioning correctly before publishing this page normally.

protected
bool
hasStaticPage()

Determine if static content is cached for this page

public
true
writeStaticPage()

Write out the published version of the page to the filesystem.

public
array
fieldLabels(bool $includerelations = true)

No description

public static 
string|null
get_content_for_errorcode(int $statusCode)

Returns statically cached content for a given error code

protected
getCodes()

No description

protected static 
string
get_error_filename(int $statusCode, ErrorPage $instance = null)

Gets the filename identifier for the given error code.

protected
string
getErrorFilename()

Get filename identifier for this record.

protected static 
get_asset_handler()

No description

Details

bool canAddChildren($member = null)

No description

Parameters

$member

Return Value

bool

static HTTPResponse response_for(int $statusCode, string|null $errorMessage = null)

Get a HTTPResponse to response to a HTTP error code if an ErrorPage for that code is present. First tries to serve it through the standard SilverStripe request method. Falls back to a static file generated when the user hit's save and publish in the CMS

Parameters

int $statusCode
string|null $errorMessage

A developer message to put in the response on dev envs

Return Value

HTTPResponse

Exceptions

HTTPResponse_Exception

requireDefaultRecords()

Ensures that there is always a 404 page by checking if there's an instance of ErrorPage with a 404 and 500 error code. If there is not, one is created when the DB is built.

Exceptions

ValidationException

protected requireDefaultRecordFixture(array $defaultData)

Build default record from specification fixture

Parameters

array $defaultData

Exceptions

ValidationException

protected array getDefaultRecords()

Returns an array of arrays, each of which defines properties for a new ErrorPage record.

Return Value

array

FieldList getCMSFields()

No description

Return Value

FieldList

bool publishSingle()

When an error page is published, create a static HTML page with its content, so the page can be shown even when SilverStripe is not functioning correctly before publishing this page normally.

Return Value

bool

True if published

protected bool hasStaticPage()

Determine if static content is cached for this page

Return Value

bool

true writeStaticPage()

Write out the published version of the page to the filesystem.

Return Value

true

if the page write was successful

array fieldLabels(bool $includerelations = true)

No description

Parameters

bool $includerelations

a boolean value to indicate if the labels returned include relation fields

Return Value

array

static string|null get_content_for_errorcode(int $statusCode)

Returns statically cached content for a given error code

Parameters

int $statusCode

A HTTP Statuscode, typically 404 or 500

Return Value

string|null

protected getCodes()

No description

static protected string get_error_filename(int $statusCode, ErrorPage $instance = null)

Gets the filename identifier for the given error code.

Used when handling responses under error conditions.

Parameters

int $statusCode

A HTTP Statuscode, typically 404 or 500

ErrorPage $instance

Optional instance to use for name generation

Return Value

string

protected string getErrorFilename()

Get filename identifier for this record.

Used for generating the filename for the current record.

Return Value

string

static protected GeneratedAssetHandler get_asset_handler()

No description

Return Value

GeneratedAssetHandler