Hey, just got my head around how to setup an event listener via the
configuration:

services:
    my_listerner_service_name:
        class: Namespace\For\My\Listener\CustomListener
        tags:
            - { name: kernel.listener, priority: 0 }

Then you need to create your class (Namespace\For\My\Listener
\CustomListener) with a 'register' method.

But I'm thinking (magento experience) this could be simplified.
Configuration could simply be this:

listeners:
    event_name_sting:
        class: Namespace\For\My\Listener\CustomListener
        method: observe
        singleton: true
        priority: 0

There will be a class/bundle that knows how to compile this, but the
logic is simply, when the event 'event_name_sting' is dispatched, the
class Namespace\For\My\Listener\CustomListener is initiated and the
method 'observe' (which has only one argument - Event object) is
called.

Note: the singleton parameter, should give added functionality so the
listener created should be kept in memory and not recreated if it were
to be called again for another event ... possibly through another
method.

What you guys think ... or can already be done?

M.



-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-devs?hl=en

Reply via email to