Index

DocumentOptions

MMO\core\documents · 1 symbol · generated 30 Sep 2026

class

DocumentOptions

DocumentOptions.php:25

A document's options as named arguments, for its constructor: new HtmlDocument(null, new DocumentOptions(...)) stands for new HtmlDocument(null, ['raw' => true, ...]), and a misspelled option is an error instead of being ignored.

final readonly class MMO\core\documents\DocumentOptions implements MMO\core\interfaces\iOptions
Namespace
MMO\core\documents
Implements
iOptions
`print` holds the options of every value the document renders: with `print: new PrintOptions(escape: true)`, an HtmlDocument HTML-escapes each value its templates print through `$this->renderValue()` (the page's own markup is left as it is), so a template cannot forget to. An option left null is not set: the document's default applies.
//every value rendered by the page's templates is HTML-escaped $document = new HtmlDocument(null, new DocumentOptions(print: new PrintOptions(escape: true)));//an e-mail: no CSS nor JS added to the page $mail = new HtmlDocument(null, new DocumentOptions(raw: true));

Properties5

charset

readonly
readonly ?string $charset
Type
null | string

print

readonly
readonly ?MMO\core\printers\PrintOptions $print
Type
null | PrintOptions

printer

readonly
readonly ?object $printer
Type
null | object

raw

readonly
readonly ?bool $raw
Type
null | bool

vars

readonly
readonly ?array $vars
Type
null | array

Methods2

toArray()

DocumentOptions.php:48
function toArray(): array
returnsarraymixed> the options that are set, the printer's among them: a document keeps them in one list
(new DocumentOptions(raw: true, print: new PrintOptions(escape: true)))->toArray(); // ['escape' => true, 'raw' => true]

__construct($raw, $charset, $printer, $vars, $print)

DocumentOptions.php:36
function __construct( ?bool $raw = null, ?string $charset = null, ?object $printer = null, ?array $vars = null, ?MMO\core\printers\PrintOptions $print = null )
See
Document::addVars()
$raw = nullnull | boolthe document as plain as its format allows: an HtmlDocument without the CSS and JS it adds (e.g. an e-mail), a JsonDocument without its meta/links/logs envelope. Document::setRaw()
$charset = nullnull | stringXmlDocument, HtmlDocument: the charset it declares (default 'utf-8').
$printer = nullnull | objectthe invokable printer of its values, e.g. HtmlPrinter::Shared() (default: the one of its format). Document::setPrinter()
$vars = nullnull | array
$print = nullnull | PrintOptionsthe options of every value it renders.