After triing arround to implement eventhandling in Symfony3 and I came up with a following solution.
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 yaml snippet can be placed in a file "custom_events.yml" in app/config
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