diff --git a/docs/developer/src/events.md b/docs/developer/src/events.md index d597462073..627f56d15c 100644 --- a/docs/developer/src/events.md +++ b/docs/developer/src/events.md @@ -45,10 +45,10 @@ Example 1: Adding elements to the core UI * @param array $vars Input from the caller/emitter * @param array $res I/O parameter used to accumulate or return values from the listener to the emitter * - * @return bool true if not handled or if the handling should be accumulated with other listeners, + * @return \EventResult true if not handled or if the handling should be accumulated with other listeners, * false if handled well enough and no other listeners are needed */ -public function onViewAttachmentImage(array $vars, array &$res): bool +public function onViewAttachmentImage(array $vars, array &$res): \EventResult { $res[] = Formatting::twigRenderFile('imageEncoder/imageEncoderView.html.twig', ['attachment' => $vars['attachment'], 'thumbnail_parameters' => $vars['thumbnail_parameters']]); return Event::stop; @@ -74,11 +74,25 @@ Event::handle('ResizerAvailable', [&$event_map]); /** * @param array $event_map output * - * @return bool event hook + * @return \EventResult event hook */ -public function onResizerAvailable(array &$event_map): bool +public function onResizerAvailable(array &$event_map): \EventResult { $event_map['image'] = 'ResizeImagePath'; return Event::next; } -``` \ No newline at end of file +``` + +Example 3: Default action +----- + +An event can be emited to perform an action, but still have a fallback as such: + +> Event emitter + +```php +if (Event::handle('EventName', $args) !== Event::stop): \EventResult +{ + // Do default action, as no-one claimed authority on handling this event +} +```