DocumentInit
MMO\core\events · 1 symbol · generated 30 Sep 2026
DocumentInit
DocumentInit.php:18Dispatched whenever a document's body is (re)set (from Document::__construct or Document::setBody), letting listeners inspect or react to the new body (e.g. logging, validation, normalization hooks).
Index
| document readonly | The document whose body was just set. | |
| Listeners static | ||
| AddListener($handler, $order) static | Register a listener directly (as opposed to ConnectListeners's attribute-based discovery). | |
| 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 … | |
| getOrigin() | ||
| HasListener($handler) static | ||
| 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). | |
| __construct($document) |
Properties2
document
readonlyThe document whose body was just set.
- Type
- Document
Listeners
static- Type
- array
Methods12
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 |
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()
DocumentInit.php:35GetListeners()
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], ...] |
getOrigin()
DocumentInit.php:30HasListener($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 |
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).
__construct($document)
DocumentInit.php:25| $document | Document |