Index

XmlDocument

MMO\core\documents · 1 symbol · generated 5 Oct 2026

class

XmlDocument

XmlDocument.php:20

A Document whose body is an XML tree (XmlNodes/XmlNode) instead of a plain array, rendered via XmlPrinter. Unless built Document::Raw(), the body starts with a <SERVER id="mmoconsole"> node (createBody) that logEvent appends recorded Log entries into, so logs show up inline in the rendered XML (as comments -- see XmlPrinter::exportLog) instead of only via

class MMO\core\documents\XmlDocument extends MMO\core\documents\Document
Namespace
MMO\core\documents
Extends
Document
See
getLogs().
$doc = XmlDocument::Raw(); // raw: no console node, so <item> is the only root element $doc[] = $doc->createNode('item', ['id' => 1], ['hello']); // createNode() builds the node, `[] =` adds it echo $doc->render(); // the XML declaration, then <item id="1">hello</item>

Index

absoluteUrl($url)Resolve $url against this document's own URL (getUrl), or against the application's own base URL if this document has none.
createBody($charset, $opts)Build the initial body: just the XML declaration when Document::isRaw, otherwise the declaration plus an empty <SERVER id="mmoconsole"> node (kept in $logs, see logEvent) that reco…
createNode($tag, $attrs, $nodes)Build a new XML node (XmlNodes::create), without adding it to the document: there is no one right place for it.
getUrl()
setLogs($logs)Replace the whole log collection.
setUrl($url)Set this document's canonical URL (as a 'current' link -- see LinkProviderInterface), used as the base for absoluteUrl.
__construct($body, $opts)

Methods7

absoluteUrl($url)

XmlDocument.php:86

Resolve $url against this document's own URL (getUrl), or against the application's own base URL if this document has none.

function absoluteUrl(string $url): string
$urlstringan absolute or relative URL.
returnsstring

createBody($charset, $opts)

XmlDocument.php:41

Build the initial body: just the XML declaration when Document::isRaw, otherwise the declaration plus an empty <SERVER id="mmoconsole"> node (kept in $logs, see logEvent) that recorded logs are rendered into.

protected function createBody(string $charset, array $opts = []): MMO\core\helpers\XmlNodes
$charsetstring
$opts = []array
returnsXmlNodes

createNode($tag, $attrs, $nodes)

XmlDocument.php:102

Build a new XML node (XmlNodes::create), without adding it to the document: there is no one right place for it. Add it yourself -- $doc[] = $node at the root of the body (a second root element next to the <SERVER> console node, unless the document is Document::Raw), $doc['body'][] = $node in an

function createNode(?string $tag = null, array $attrs = [], array $nodes = []): MMO\core\helpers\XmlNodes
See
HtmlDocument's <body>.
$tag = nullnull | stringthe tag name (null for a fragment: an XmlNodes of $nodes, with no tag).
$attrs = []array
$nodes = []arraychild nodes/content.
returnsXmlNodesthe new node, attached to nothing.
$page['body'][] = $page->createNode('p', ['class' => 'note'], ['Saved.']); // $page: an HtmlDocument

getUrl()

XmlDocument.php:76
function getUrl(): ?string
returnsnull | stringthe 'current' link's href, falling back to the 'canonical' link's, or null if neither is set.

setLogs($logs)

XmlDocument.php:56

Replace the whole log collection. Unlike the parent (a plain array), here $logs is normally the <SERVER> XML node embedded in the body (see createBody) -- so this also updates the body tree: swaps in $logs itself if it's a detached (parent-less) XML node, otherwise just removes the old node.

function setLogs(MMO\core\interfaces\iArray|array &$logs): void
$logsiArray | array
returnsvoid

setUrl($url)

XmlDocument.php:70

Set this document's canonical URL (as a 'current' link -- see LinkProviderInterface), used as the base for absoluteUrl. Updates the existing 'current' link if there is one, otherwise adds one.

function setUrl(string $url): void
$urlstring
returnsvoid
Inherited members (50)
PropertiesDeclared byDescription
bodyDocument
importPathsDocument
linksDocument
logsDocument
metaDocumentFree-form metadata about this document (e.g.
optsDocument
readOnlyDocumentIf true, the document's body/links/meta can no longer be modified (setters throw eRuntime).
MethodsDeclared byDescription
addContent($data)DocumentRecursively merge $data into the current body (see merge).
addImportPath($path, $first)DocumentAdd one base directory to the import search paths.
addLink($link)DocumentAppend a link to this document.
addMeta($data)DocumentRecursively merge $data into $meta (existing keys are overwritten, not combined -- see merge's $combine argument).
addOptions($opts, $appendList)DocumentMerge $opts into the existing options (through merge), rather than replacing them wholesale like setOptions.
addVars($vars)DocumentMerge extra variables into the set made available to import()-ed files.
clearLogs()DocumentDiscard all recorded logs.
clearOptions()DocumentEmpty the options bag.
createStream()Document
findImportPath($filename)DocumentResolve a relative filename against getImportPaths (first match wins).
getBody()Document
getImportPaths()Document
getLinkByRel($rel)Document
getLinks()DocumentReturns an iterable of LinkInterface objects.
getLinksByRel($rel)DocumentReturns an iterable of LinkInterface objects that have a specific relationship.
getLogs()Document
getOption($key, $default)Document
getOptions()Document
getPrinter()Document
getVars()DocumentGet the variables available for import
hasLogs($flag)Document
import($_FILENAME, $_VARS, $_KEY)DocumentImport (require) a PHP/phtml file as a sub-template, capturing its output.
isImportValid($filename)Document
isRaw()Document
jsonSerialize()Document
logEvent($event)DocumentRecord a log/event on this document, e.g.
offsetExists($offset)DocumentArrayAccess: isset($document[$offset]) -- true for a body entry with a non-null value, or, when the body is a plain array, for any existing key (including one whose value is null).
offsetGet($offset)DocumentArrayAccess: $document[$offset] -- returns null for a missing entry, same as `$document[$offset] ??
offsetSet($offset, $value)DocumentArrayAccess: $document[$offset] = $value sets a body entry ($document[] = $value appends).
offsetUnset($offset)DocumentArrayAccess: unset($document[$offset]) removes a body entry.
Raw($body, $opts)DocumentBuild a document whose isRaw is true from the start (see setRaw for what "raw" means).
removeLink($link)DocumentRemove a link (by identity).
render($opts)DocumentExport view to string
renderValue($value, $opts)DocumentRender an arbitrary value through this document's printer (getPrinter, or TextPrinter by default), merging $opts over the document's own options.
setBody($body)DocumentReplace the document's content, then dispatch DocumentInit.
setImportPaths($paths)DocumentReplace the base directories searched by findImportPath/import for a relative filename.
setOption($key, $value)DocumentSet (or, with a null $value, remove) a single option.
setOptions($opts)DocumentReplace the whole options bag.
setPrinter($printer)Document
setRaw($raw)DocumentTells a document should be left as raw as possible.
setVars($vars)DocumentReplace the variables made available to import()-ed files (a 'document' => $this var is always added at construction, see __construct).
startCapture($key)DocumentStart output capture.
__toString()Document