File tree Expand file tree Collapse file tree 2 files changed +10
-9
lines changed
src/AppBundle/EventListener Expand file tree Collapse file tree 2 files changed +10
-9
lines changed Original file line number Diff line number Diff line change @@ -111,12 +111,5 @@ services:
111
111
AppBundle\EventListener\RedirectToPreferredLocaleSubscriber :
112
112
$locales : ' %app_locales%'
113
113
114
- # Event Listeners are classes that listen to one or more specific events.
115
- # Those events are defined in the tags added to the service definition.
116
- # See http://symfony.com/doc/current/event_dispatcher.html#creating-an-event-listener
117
- AppBundle\EventListener\CommentNotificationListener :
114
+ AppBundle\EventListener\CommentNotificationSubscriber :
118
115
$sender : ' %app.notifications.email_sender%'
119
- # The "method" attribute of this tag is optional and defaults to "on + camelCasedEventName"
120
- # If the event is "comment.created" the method executed by default is "onCommentCreated()".
121
- tags :
122
- - { name: kernel.event_listener, event: comment.created, method: onCommentCreated }
Original file line number Diff line number Diff line change 12
12
namespace AppBundle \EventListener ;
13
13
14
14
use AppBundle \Entity \Comment ;
15
+ use Symfony \Component \EventDispatcher \EventSubscriberInterface ;
15
16
use Symfony \Component \EventDispatcher \GenericEvent ;
16
17
use Symfony \Component \Routing \Generator \UrlGeneratorInterface ;
17
18
use Symfony \Component \Translation \TranslatorInterface ;
21
22
*
22
23
* @author Oleg Voronkovich <oleg-voronkovich@yandex.ru>
23
24
*/
24
- class CommentNotificationListener
25
+ class CommentNotificationSubscriber implements EventSubscriberInterface
25
26
{
26
27
/**
27
28
* @var \Swift_Mailer
@@ -95,4 +96,11 @@ public function onCommentCreated(GenericEvent $event)
95
96
// See http://symfony.com/doc/current/email/dev_environment.html#viewing-from-the-web-debug-toolbar
96
97
$ this ->mailer ->send ($ message );
97
98
}
99
+
100
+ public static function getSubscribedEvents ()
101
+ {
102
+ return [
103
+ 'comment.created ' => 'onCommentCreated ' ,
104
+ ];
105
+ }
98
106
}
You can’t perform that action at this time.
0 commit comments