tException
MMO\core\classes · 1 symbol · generated 30 Sep 2026
tException
tException.php:16Trait giving an exception class placeholder-based, i18n-aware messages: the constructor takes a {xxx}-style $format and a $context array (like the framework's logging functions), renders them into the final message, and also makes the exception class itself an tEvent event bus: \MMO\core\Application's top-level error handler calls $e->dispatch() on every uncaught iException, so listeners registered on a specific exception class (e.g. eNotFound::AddListener(...)) can react whenever that exception type goes uncaught.
- Namespace
MMO\core\classes- Uses traits
- tEvent
Index
| context | ||
| format | ||
| 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. | |
| getContext() | ||
| getFormat() | ||
| 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 | ||
| jsonSerialize() | \JsonSerializable::jsonSerialize | |
| 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($origin, $format, $context, $previous, $code) |
Properties3
context
- Type
- array
format
- Type
- string
Listeners
static- Type
- array
Methods14
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 |
getContext()
tException.php:48- See
getFormatintoException::getMessage
| returns | the raw placeholder values passed to the constructor (plus 'origin'), as used to render |
getFormat()
tException.php:56| returns | the original, untranslated {xxx}-placeholder message format passed to the constructor |
GetListeners()
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()
tException.php:65| returns | object | string | whatever was passed as $origin to the constructor (typically the object -- or its class name -- that threw the exception) |
HasListener($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 |
jsonSerialize()
tException.php:74\JsonSerializable::jsonSerialize
| returns | mixed | string, trace: array} |
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($origin, $format, $context, $previous, $code)
tException.php:31| $origin | the exception origin (object throwing) | |
| $format | string | the message's format. Can contain placeholders {xxx} replaced by values in context. {origin} is replaced by origin. |
| $context = [] | array | the message context. |
| $previous = null | null | Throwable | |
| $code = 0 | int |