class ErrorDocument extends Document

ErrorDocument class, provides an easy interface to parse and display an error page

Properties

string $title Document title from Document
string $description Document description from Document
Document full URL from Document
string $base Document base URL from Document
string $language Contains the document language setting from Document
string $direction Contains the document direction setting from Document
string $_generator Document generator from Document
string|Date $_mdate Document modified date from Document
string $_tab Tab string from Document
string $_lineEnd Contains the line end string from Document
string $_charset Contains the character encoding string from Document
string $_mime Document mime type from Document
string $_namespace Document namespace from Document
string $_profile Document profile from Document
array $_scripts Array of linked scripts from Document
array $_script Array of scripts placed in the header from Document
array $_styleSheets Array of linked style sheets from Document
array $_style Array of included style declarations from Document
array $_metaTags Array of meta tags from Document
object $_engine The rendering engine from Document
string $_type The document type from Document
static mixed $_buffer Array of buffered output from Document
string $baseurl Document base URL
boolean $debug Flag if debug mode has been enabled
Exception|Throwable $error Error Object
string $template Name of the template
array $_file File name

Methods

__construct( array $options = array())

Class constructor

static  object
getInstance( string $type = 'html', array $attributes = array())

Returns the global Document object, only creating it if it doesn't already exist.

from Document
setType( string $type)

Set the document type

from Document
string
getType()

Returns the document type

from Document
mixed
getBuffer()

Get the contents of the document buffer

from Document
setBuffer( string $content, array $options = array())

Set the contents of the document buffer

from Document
string
getMetaData( string $name, string $attribute = 'name')

Gets a meta tag.

from Document
setMetaData( string $name, mixed $content, string $attribute = 'name')

Sets or alters a meta tag.

from Document
addScript( string $url, array $options = array(), array $attribs = array())

Adds a linked script to the page

from Document
addScriptVersion( string $url, array $options = array(), array $attribs = array())

Adds a linked script to the page with a version to allow to flush it. Ex: myscript.js?54771616b5bceae9df03c6173babf11d If not specified Joomla! automatically handles versioning

from Document
addScriptDeclaration( string $content, string $type = 'text/javascript')

Adds a script to the page

from Document
addScriptOptions( string $key, mixed $options, bool $merge = true)

Add option for script

from Document
array
getScriptOptions( string $key = null)

Get script(s) options

from Document
addStyleSheet( string $url, array $options = array(), array $attribs = array())

Adds a linked stylesheet to the page

from Document
addStyleSheetVersion( string $url, array $options = array(), array $attribs = array())

Adds a linked stylesheet version to the page. Ex: template.css?54771616b5bceae9df03c6173babf11d If not specified Joomla! automatically handles versioning

from Document
addStyleDeclaration( string $content, string $type = 'text/css')

Adds a stylesheet declaration to the page

from Document
setCharset( string $type = 'utf-8')

Sets the document charset

from Document
string
getCharset()

Returns the document charset encoding.

from Document
setLanguage( string $lang = 'en-gb')

Sets the global document language declaration. Default is English (en-gb).

from Document
string
getLanguage()

Returns the document language.

from Document
setDirection( string $dir = 'ltr')

Sets the global document direction declaration. Default is left-to-right (ltr).

from Document
string
getDirection()

Returns the document direction declaration.

from Document
setTitle( string $title)

Sets the title of the document

from Document
string
getTitle()

Return the title of the document.

from Document
setMediaVersion( string $mediaVersion)

Set the assets version

from Document
string
getMediaVersion()

Return the media version

from Document
setBase( string $base)

Sets the base URI of the document

from Document
string
getBase()

Return the base URI of the document.

from Document
setDescription( string $description)

Sets the description of the document

from Document
string
getDescription()

Return the description of the document.

from Document
setLink( string $url)

Sets the document link

from Document
string
getLink()

Returns the document base url

from Document
setGenerator( string $generator)

Sets the document generator

from Document
string
getGenerator()

Returns the document generator

from Document
setModifiedDate( string|Date $date)

Sets the document modified date

from Document
string|Date
getModifiedDate()

Returns the document modified date

from Document
setMimeEncoding( string $type = 'text/html', boolean $sync = true)

Sets the document MIME encoding that is sent to the browser.

from Document
string
getMimeEncoding()

Return the document MIME encoding that is sent to the browser.

from Document
setLineEnd( string $style)

Sets the line end style to Windows, Mac, Unix or a custom string.

from Document
string
_getLineEnd()

Returns the lineEnd

from Document
setTab( string $string)

Sets the string used to indent HTML

from Document
string
_getTab()

Returns a string containing the unit for indenting HTML

from Document
loadRenderer( string $type)

Load a renderer

from Document
parse( array $params = array())

Parses the document and prepares the buffers

from Document
void
render( boolean $cache = false, array $params = array())

Render the document

boolean
setError( Exception|Throwable $error)

Set error object

string
_loadTemplate( string $directory, string $filename)

Load a template file

string
renderBacktrace()

Render the backtrace

Details

__construct( array $options = array())

Class constructor

Parameters

array $options Associative array of options

static object getInstance( string $type = 'html', array $attributes = array())

Returns the global Document object, only creating it if it doesn't already exist.

Parameters

string $type The document type to instantiate
array $attributes Array of attributes

Return Value

object The document object.

Document setType( string $type)

Set the document type

Parameters

string $type Type document is to set to

Return Value

Document instance of $this to allow chaining

string getType()

Returns the document type

Return Value

string

mixed getBuffer()

Get the contents of the document buffer

Return Value

mixed

Document setBuffer( string $content, array $options = array())

Set the contents of the document buffer

Parameters

string $content The content to be set in the buffer.
array $options Array of optional elements.

Return Value

Document instance of $this to allow chaining

string getMetaData( string $name, string $attribute = 'name')

Gets a meta tag.

Parameters

string $name Name of the meta HTML tag
string $attribute Attribute to use in the meta HTML tag

Return Value

string

Document setMetaData( string $name, mixed $content, string $attribute = 'name')

Sets or alters a meta tag.

Parameters

string $name Name of the meta HTML tag
mixed $content Value of the meta HTML tag as array or string
string $attribute Attribute to use in the meta HTML tag

Return Value

Document instance of $this to allow chaining

Document addScript( string $url, array $options = array(), array $attribs = array())

Adds a linked script to the page

Parameters

string $url URL to the linked script.
array $options Array of options. Example: array('version' => 'auto', 'conditional' => 'lt IE 9')
array $attribs Array of attributes. Example: array('id' => 'scriptid', 'async' => 'async', 'data-test' => 1)

Return Value

Document instance of $this to allow chaining

Document addScriptVersion( string $url, array $options = array(), array $attribs = array())

Adds a linked script to the page with a version to allow to flush it. Ex: myscript.js?54771616b5bceae9df03c6173babf11d If not specified Joomla! automatically handles versioning

Parameters

string $url URL to the linked script.
array $options Array of options. Example: array('version' => 'auto', 'conditional' => 'lt IE 9')
array $attribs Array of attributes. Example: array('id' => 'scriptid', 'async' => 'async', 'data-test' => 1)

Return Value

Document instance of $this to allow chaining

Document addScriptDeclaration( string $content, string $type = 'text/javascript')

Adds a script to the page

Parameters

string $content Script
string $type Scripting mime (defaults to 'text/javascript')

Return Value

Document instance of $this to allow chaining

Document addScriptOptions( string $key, mixed $options, bool $merge = true)

Add option for script

Parameters

string $key Name in Storage
mixed $options Scrip options as array or string
bool $merge Whether merge with existing (true) or replace (false)

Return Value

Document instance of $this to allow chaining

array getScriptOptions( string $key = null)

Get script(s) options

Parameters

string $key Name in Storage

Return Value

array Options for given $key, or all script options

Document addStyleSheet( string $url, array $options = array(), array $attribs = array())

Adds a linked stylesheet to the page

Parameters

string $url URL to the linked style sheet
array $options Array of options. Example: array('version' => 'auto', 'conditional' => 'lt IE 9')
array $attribs Array of attributes. Example: array('id' => 'stylesheet', 'data-test' => 1)

Return Value

Document instance of $this to allow chaining

Document addStyleSheetVersion( string $url, array $options = array(), array $attribs = array())

Adds a linked stylesheet version to the page. Ex: template.css?54771616b5bceae9df03c6173babf11d If not specified Joomla! automatically handles versioning

Parameters

string $url URL to the linked style sheet
array $options Array of options. Example: array('version' => 'auto', 'conditional' => 'lt IE 9')
array $attribs Array of attributes. Example: array('id' => 'stylesheet', 'data-test' => 1)

Return Value

Document instance of $this to allow chaining

Document addStyleDeclaration( string $content, string $type = 'text/css')

Adds a stylesheet declaration to the page

Parameters

string $content Style declarations
string $type Type of stylesheet (defaults to 'text/css')

Return Value

Document instance of $this to allow chaining

Document setCharset( string $type = 'utf-8')

Sets the document charset

Parameters

string $type Charset encoding string

Return Value

Document instance of $this to allow chaining

string getCharset()

Returns the document charset encoding.

Return Value

string

Document setLanguage( string $lang = 'en-gb')

Sets the global document language declaration. Default is English (en-gb).

Parameters

string $lang The language to be set

Return Value

Document instance of $this to allow chaining

string getLanguage()

Returns the document language.

Return Value

string

Document setDirection( string $dir = 'ltr')

Sets the global document direction declaration. Default is left-to-right (ltr).

Parameters

string $dir The language direction to be set

Return Value

Document instance of $this to allow chaining

string getDirection()

Returns the document direction declaration.

Return Value

string

Document setTitle( string $title)

Sets the title of the document

Parameters

string $title The title to be set

Return Value

Document instance of $this to allow chaining

string getTitle()

Return the title of the document.

Return Value

string

Document setMediaVersion( string $mediaVersion)

Set the assets version

Parameters

string $mediaVersion Media version to use

Return Value

Document instance of $this to allow chaining

string getMediaVersion()

Return the media version

Return Value

string

Document setBase( string $base)

Sets the base URI of the document

Parameters

string $base The base URI to be set

Return Value

Document instance of $this to allow chaining

string getBase()

Return the base URI of the document.

Return Value

string

Document setDescription( string $description)

Sets the description of the document

Parameters

string $description The description to set

Return Value

Document instance of $this to allow chaining

string getDescription()

Return the description of the document.

Return Value

string

Sets the document link

Parameters

string $url A url

Return Value

Document instance of $this to allow chaining

Returns the document base url

Return Value

string

Document setGenerator( string $generator)

Sets the document generator

Parameters

string $generator The generator to be set

Return Value

Document instance of $this to allow chaining

string getGenerator()

Returns the document generator

Return Value

string

Document setModifiedDate( string|Date $date)

Sets the document modified date

Parameters

string|Date $date The date to be set

Return Value

Document instance of $this to allow chaining

Exceptions

InvalidArgumentException

string|Date getModifiedDate()

Returns the document modified date

Return Value

string|Date

Document setMimeEncoding( string $type = 'text/html', boolean $sync = true)

Sets the document MIME encoding that is sent to the browser.

This usually will be text/html because most browsers cannot yet accept the proper mime settings for XHTML: application/xhtml+xml and to a lesser extent application/xml and text/xml. See the W3C note ({@link http://www.w3.org/TR/xhtml-media-types/ http://www.w3.org/TR/xhtml-media-types/}) for more details.

Parameters

string $type The document type to be sent
boolean $sync Should the type be synced with HTML?

Return Value

Document instance of $this to allow chaining

string getMimeEncoding()

Return the document MIME encoding that is sent to the browser.

Return Value

string

Document setLineEnd( string $style)

Sets the line end style to Windows, Mac, Unix or a custom string.

Parameters

string $style "win", "mac", "unix" or custom string.

Return Value

Document instance of $this to allow chaining

string _getLineEnd()

Returns the lineEnd

Return Value

string

Document setTab( string $string)

Sets the string used to indent HTML

Parameters

string $string String used to indent ("\11", "\t", ' ', etc.).

Return Value

Document instance of $this to allow chaining

string _getTab()

Returns a string containing the unit for indenting HTML

Return Value

string

DocumentRenderer loadRenderer( string $type)

Load a renderer

Parameters

string $type The renderer type

Return Value

DocumentRenderer

Exceptions

RuntimeException

Document parse( array $params = array())

Parses the document and prepares the buffers

Parameters

array $params The array of parameters

Return Value

Document instance of $this to allow chaining

void render( boolean $cache = false, array $params = array())

Render the document

Parameters

boolean $cache If true, cache the output
array $params Associative array of attributes

Return Value

void The rendered data

boolean setError( Exception|Throwable $error)

Set error object

Parameters

Exception|Throwable $error Error object to set

Return Value

boolean True on success

string _loadTemplate( string $directory, string $filename)

Load a template file

Parameters

string $directory The name of the template
string $filename The actual filename

Return Value

string The contents of the template

string renderBacktrace()

Render the backtrace

Return Value

string The contents of the backtrace