Given: There is a event "thumbnail.finedata.created".
You have a listenerclass :
"Mittax\MediaConverterBundle\Event\Listener\Thumbnail\FineDataCreated"
And a method : onFineDataCreated() which takes the event.
In Symfony 3 there is a simple way to configure the eventlistener in default config.yml without to register the event in custom code.
The eventlistener is simply a tagged service. So Symfony knows it's event listeners by configuration.
Step 1:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
services: | |
thumbnail.finedata.created: | |
class: Mittax\MediaConverterBundle\Event\Listener\Thumbnail\FineDataCreated | |
tags: | |
- { name: kernel.event_listener, event: thumbnail.finedata.created, priority: 1 } |
Step 2:
Import the new file in app/config.yml after service.yml
That`s it.
Now you can check your event with
php bin/console debug:event-dispatcher <your eventname>
Thx to mablae for this tut.
Keine Kommentare:
Kommentar veröffentlichen