[DOCS] Expand developer Event documentation

v3
Hugo Sales 2 years ago
parent d4b7e990ce
commit a2aa45fb1f
No known key found for this signature in database
GPG Key ID: 7D0C7EAFC9D835A0

@ -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;
}
```
```
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
}
```

Loading…
Cancel
Save