DocumentRender
MMO\core\events · 1 symbol · generated 30 Sep 2026
DocumentRender
DocumentRender.php:23Dispatched by Document::render(), letting a listener supply the rendered output itself (via setReturn) instead of the document's default printer -- e.g. to inject caching, post-processing, or an alternate format.
- Namespace
MMO\core\events- Implements
- iStoppableEvent, iSignal
- Uses traits
- tEvent, tStoppableEvent, tWithOptions
Index
| document | The document being rendered. | |
| Listeners static | ||
| opts | ||
| return | ||
| stopped | ||
| AddListener($handler, $order) static | Register a listener directly (as opposed to ConnectListeners's attribute-based discovery). | |
| addOptions($opts, $appendList) | Merge $opts into the existing options (through merge), rather than replacing them wholesale like setOptions. | |
| clearOptions() | Empty the options bag. | |
| ConnectListeners($obj) static | Scan $obj's methods for #[Listen(EventClass::class)] attributes and register each one as a listener on the matching event class. | |
| DisconnectListeners($obj) static | Undo a previous ConnectListeners: removes every listener that connect had registered for $obj on this event class. | |
| dispatch() | Invoke every GetListeners listener with $this. | |
| getBody() | ||
| GetListeners() static | Collect every listener for this class, including those registered on its parent classes (so a subclass event is also caught by listeners of its parent event), sorted by ascending $order (ties keep … | |
| getOption($key, $default) | ||
| getOptions() | ||
| getOrigin() | ||
| getReturn() | ||
| HasListener($handler) static | ||
| isPropagationStopped() | ||
| RemoveListener($handler) static | Remove the last added handler from the listeners. | |
| Send($args) static | Construct a new instance of this class with $args, then dispatch it to every listener. | |
| SetListenerOrder($handler, $order) static | Change the order of an already-registered listener, whether added directly via AddListener or indirectly via ConnectListeners (which also stores its [$obj, $methodName] callables here). | |
| setOption($key, $value) | Set (or, with a null $value, remove) a single option. | |
| setOptions($opts) | Replace the whole options bag. | |
| setReturn($output, $stop) | Override the rendered output, e.g. | |
| stopPropagation() | Prevent any remaining listener in the current dispatch chain from being called. | |
| __clone() | A cloned event starts fresh: propagation is never considered stopped on the clone, even if it was on the original instance. | |
| __construct($document, $opts) |
Properties5
document
The document being rendered.
- Type
- Document
Listeners
static- Type
- array
opts
- Type
- array
return
stopped
Methods23
AddListener($handler, $order)
statictEvent.php:62Register a listener directly (as opposed to ConnectListeners's attribute-based discovery).
| $handler | callable | called as $handler($eventInstance) when this event class is Send / dispatch-ed |
| $order = 0 | int | listeners run in ascending order (lower first); listeners with an equal order run in the order they were added |
| returns | void |
addOptions($opts, $appendList)
tWithOptions.php:65Merge $opts into the existing options (through merge), rather than replacing them wholesale like setOptions.
| $opts | array | the options to merge in |
| $appendList = false | bool | if true, a list-valued option is appended to (rather than replaced by) the corresponding list in $opts -- see \MMO\core\arrays\merge for the exact semantics |
| returns | void |
clearOptions()
tWithOptions.php:39Empty the options bag.
| returns | void |
ConnectListeners($obj)
statictEvent.php:37Scan $obj's methods for #[Listen(EventClass::class)] attributes and register each one as a listener on the matching event class. connect does the actual reflection/registration.
DisconnectListeners($obj)
statictEvent.php:49Undo a previous ConnectListeners: removes every listener that connect had registered for $obj on this event class.
dispatch()
tEvent.php:153Invoke every GetListeners listener with $this. If the class also implements PSR-14's StoppableEventInterface, dispatch stops early as soon as isPropagationStopped() becomes true.
| returns | static | $this, for chaining |
getBody()
DocumentRender.php:45GetListeners()
statictEvent.php:123Collect every listener for this class, including those registered on its parent classes (so a subclass event is also caught by listeners of its parent event), sorted by ascending $order (ties keep insertion order).
| returns | array | [[callable $handler, int $order], ...] |
getOption($key, $default)
tWithOptions.php:49getOptions()
tWithOptions.php:20| returns | array | every option currently set |
getOrigin()
DocumentRender.php:40getReturn()
DocumentRender.php:53HasListener($handler)
statictEvent.php:109| $handler | callable | object | either the exact callable passed to AddListener, or (for a [$obj, $methodName] listener registered via ConnectListeners) just the object, to check whether any of its methods are currently listening |
| returns | bool |
isPropagationStopped()
tStoppableEvent.php:21| returns | bool | true once stopPropagation has been called on this instance |
RemoveListener($handler)
statictEvent.php:91Remove the last added handler from the listeners.
Send($args)
statictEvent.php:143Construct a new instance of this class with $args, then dispatch it to every listener.
SetListenerOrder($handler, $order)
statictEvent.php:75Change the order of an already-registered listener, whether added directly via AddListener or indirectly via ConnectListeners (which also stores its [$obj, $methodName] callables here).
setOption($key, $value)
tWithOptions.php:77Set (or, with a null $value, remove) a single option.
setOptions($opts)
tWithOptions.php:30Replace the whole options bag.
setReturn($output, $stop)
DocumentRender.php:66Override the rendered output, e.g. from a listener.
stopPropagation()
tStoppableEvent.php:29Prevent any remaining listener in the current dispatch chain from being called.
| returns |
__clone()
tStoppableEvent.php:38A cloned event starts fresh: propagation is never considered stopped on the clone, even if it was on the original instance.
| returns |
__construct($document, $opts)
DocumentRender.php:34| $document | Document | |
| $opts = [] | array | render options, forwarded to the document's printer (see Document::render) |