Events
The bm_ extension dispatches events that allow you to hook into the gallery rendering process at strategic
points. These events follow TYPO3's PSR-14 event system and can be used to:
- Modify collection data
- Filter or enrich items
- Add template variables
- Implement custom business logic
Event Overview
| Event | When Dispatched | Main Purpose |
|---|---|---|
| AfterCollectionInfoResolvedEvent | After complete processing | Enrich collection info array |
| AfterItemsSortedEvent | After sort + limit | Post-process sorted items |
| BeforeRenderingEvent | Before view assignment | Add template variables |
AfterCollectionInfoResolvedEvent
Class: Freshworkx\
When is it dispatched?
- After all extension processing
- After description/preview fallbacks
- After items have been sorted (if requested)
See also
For implementation examples, see AfterCollectionInfoResolvedEvent.
AfterItemsSortedEvent
Class: Freshworkx\
When is it dispatched?
- After
FileCollector->sort() - After
maxItemslimit
See also
For implementation examples, see AfterItemsSortedEvent.
BeforeRenderingEvent
Class: Freshworkx\
When is it dispatched?
- Dispatched in all actions (list, gallery, detail)
- Before
$this->view->assignor() assignMultiple ()
See also
For implementation examples, see BeforeRenderingEvent.
Event Registration
Method 1: PHP Attribute (Recommended)
<?php
declare(strict_types=1);
namespace MyVendor\MyExtension\EventListener;
use Freshworkx\BmImageGallery\Event\AfterCollectionInfoResolvedEvent;
use TYPO3\CMS\Core\Attribute\AsEventListener;
#[AsEventListener(
identifier: 'my-ext/my-listener',
event: AfterCollectionInfoResolvedEvent::class
)]
final readonly class MyListener
{
public function __invoke(AfterCollectionInfoResolvedEvent $event): void
{
// Your logic
}
}
Ensure autoconfiguration in Configuration/:
services:
_defaults:
autowire: true
autoconfigure: true
public: false
MyVendor\MyExtension\EventListener\:
resource: '../Classes/EventListener/*'
Method 2: Services.yaml
services:
MyVendor\MyExtension\EventListener\MyListener:
tags:
- name: event.listener
identifier: 'my-ext/my-listener'
event: Freshworkx\BmImageGallery\Event\AfterCollectionInfoResolvedEvent