Document
class Document
Handles the generation and management of HTML document tags, such as meta tags, links, styles, scripts, manifest, robots, and sitemap.
Implements the singleton pattern.
Properties
| string | $title | Page title. |
|
| string | $title_append | Text to append to the title. |
|
| string | $canonical | Canonical URL of the page. |
|
| static Document|null | $instance | Singleton instance of the class. |
Methods
Returns all links added to the document.
Constructor. Sets the CSRFToken meta tag.
Generates and outputs the XML sitemap.
Generates and outputs the robots.txt file.
Generates and outputs the web manifest file.
Adds a meta tag to the document.
Returns all meta tags, or a specific one if provided.
Adds a link tag to the document.
Adds a CSS style to the document.
Adds a JS script to the document.
Adds an inline JS script to the document.
Returns rendered meta tags.
Prints rendered meta tags.
Returns rendered links and styles.
Prints rendered links and styles.
Returns rendered scripts (external and inline).
Prints rendered scripts.
Prints favicon links if available.
Details
at line 57
array
getLinks()
Returns all links added to the document.
at line 66
static Document
get()
Returns the singleton instance of the Document class.
at line 76
__construct()
Constructor. Sets the CSRFToken meta tag.
at line 89
void
sitemap()
Generates and outputs the XML sitemap.
Terminates script execution.
at line 104
void
robots()
Generates and outputs the robots.txt file.
Terminates script execution.
at line 131
void
webmanifest()
Generates and outputs the web manifest file.
Terminates script execution.
at line 160
$this
setMetaTag(string $id, array $attributes)
Adds a meta tag to the document.
at line 174
mixed
getMetaTags(string|null $tag = null)
Returns all meta tags, or a specific one if provided.
at line 189
$this
appendLink(array $attributes, array $options = [])
Adds a link tag to the document.
at line 214
$this
appendStyle(string $content, array $attributes = [], array $options = [])
Adds a CSS style to the document.
at line 234
$this
appendScript(array $attributes, array $options = [])
Adds a JS script to the document.
at line 257
$this
appendInlineScript(string $content, array $attributes = [], array $options = [])
Adds an inline JS script to the document.
at line 349
string
renderMetaTags()
Returns rendered meta tags.
at line 362
void
printMetaTags()
Prints rendered meta tags.
at line 371
string
renderStyles()
Returns rendered links and styles.
at line 392
void
printStyles()
Prints rendered links and styles.
at line 424
string
renderScripts()
Returns rendered scripts (external and inline).
at line 438
void
printScripts()
Prints rendered scripts.
at line 447
void|null
printFaviconLinks()
Prints favicon links if available.