Index

TextDocument

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

class

TextDocument

TextDocument.php:13

A plain-text Document (rendered via TextPrinter by default) that appends any recorded

class MMO\core\documents\TextDocument extends MMO\core\documents\Document
Namespace
MMO\core\documents
Extends
Document
See
Log entries after the body, one per line, instead of just exposing them via getLogs.
$doc = new TextDocument(['hello' => 'world']); echo $doc->render(); // "world" (plus any logged lines)

Methods1

render($opts)

TextDocument.php:18
function render(array $opts = []): string
$opts = []array
returnsstringthe rendered body, followed by one rendered line per recorded log (if any).
Inherited members (51)
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).
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.
setLogs($logs)Document
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.
__construct($body, $opts)DocumentConstructor
__toString()Document