SilverStripe\ErrorPage\ErrorPage
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-<statuscode>.html.
This enables us to show errors even if PHP experiences a recoverable error.
ErrorPages
Synopsis
class ErrorPage
extends Page
{
- // members
- private static array $db = ;
- private static array $defaults = ;
- private static string $table_name = 'ErrorPage';
- private static array $allowed_children = ;
- private static string $description = 'Custom content for different error cases (e.g. "Page not found")';
- private static string $icon_class = 'font-icon-p-error';
- private static boolean $dev_append_error_message = true;
- private static bool $enable_static_file = true;
- private static $store_filepath = NULL;
- // methods
- public boolean canAddChildren()
- public static HTTPResponse response_for()
- public void requireDefaultRecords()
- protected void requireDefaultRecordFixture()
- protected array getDefaultRecords()
- public FieldList getCMSFields()
- public bool publishSingle()
- protected bool hasStaticPage()
- public true writeStaticPage()
- public array fieldLabels()
- public static string|null get_content_for_errorcode()
- protected void getCodes()
- protected static string get_error_filename()
- protected string getErrorFilename()
- protected static GeneratedAssetHandler get_asset_handler()
Hierarchy
Extends
- Page
Members
private
- $allowed_children
- $db
- $defaults
- $description
- $dev_append_error_message
—
boolean
Allow developers to opt out of dev messaging using Config - $enable_static_file
—
SilverStripe\ErrorPage\bool
Allows control over writing directly to the configured `GeneratedAssetStore`. - $icon_class
- $store_filepath
—
string
Prefix for storing error files in the {@see GeneratedAssetHandler} store. - $table_name
Methods
protected
- getCodes()
- getDefaultRecords() — Returns an array of arrays, each of which defines properties for a new ErrorPage record.
- getErrorFilename() — Get filename identifier for this record.
- get_asset_handler()
- get_error_filename() — Gets the filename identifier for the given error code.
- hasStaticPage() — Determine if static content is cached for this page
- requireDefaultRecordFixture() — Build default record from specification fixture
public
- canAddChildren()
- fieldLabels()
- getCMSFields()
- get_content_for_errorcode() — Returns statically cached content for a given error code
- 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.
- 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.
- response_for() — Get a {@link HTTPResponse} to response to a HTTP error code if an {@link 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
- writeStaticPage() — Write out the published version of the page to the filesystem.