From 7b6ba9ae87261c2b2ed4745e52e009a1879bebe0 Mon Sep 17 00:00:00 2001 From: Oleg Voronkovich Date: Thu, 5 Jan 2017 19:11:32 +0300 Subject: [PATCH 01/11] Notify post author about new comments --- app/AppKernel.php | 3 +- app/Resources/translations/messages.en.xlf | 8 ++++++ app/Resources/views/blog/post_show.html.twig | 1 + app/config/config.yml | 12 ++++---- app/config/config_dev.yml | 4 +-- app/config/parameters.yml.dist | 11 +++---- src/AppBundle/Controller/BlogController.php | 30 ++++++++++++++++++++ 7 files changed, 52 insertions(+), 17 deletions(-) diff --git a/app/AppKernel.php b/app/AppKernel.php index 077c5db61..1129c08d5 100644 --- a/app/AppKernel.php +++ b/app/AppKernel.php @@ -22,8 +22,7 @@ public function registerBundles() new CodeExplorerBundle\CodeExplorerBundle(), new AppBundle\AppBundle(), new Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle(), // used for initial population of non-SQLite databases in production envs - // uncomment the following line if your application sends emails - // new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(), + new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(), ]; // Some bundles are only used while developing the application or during diff --git a/app/Resources/translations/messages.en.xlf b/app/Resources/translations/messages.en.xlf index a41d20d13..066197d13 100644 --- a/app/Resources/translations/messages.en.xlf +++ b/app/Resources/translations/messages.en.xlf @@ -276,6 +276,14 @@ post.deleted_successfully Post deleted successfully! + + post.recieved_comment + Your post recieved a comment! + + + post.recieved_comment_message + link!]]> + help.app_description diff --git a/app/Resources/views/blog/post_show.html.twig b/app/Resources/views/blog/post_show.html.twig index c574ad115..09a1c3ee5 100644 --- a/app/Resources/views/blog/post_show.html.twig +++ b/app/Resources/views/blog/post_show.html.twig @@ -30,6 +30,7 @@ {% for comment in post.comments %}
+

{{ comment.authorEmail }} {{ 'post.commented_on'|trans }} {# it's not mandatory to set the timezone in localizeddate(). This is done to diff --git a/app/config/config.yml b/app/config/config.yml index 71d345a78..2ee3b9ccc 100644 --- a/app/config/config.yml +++ b/app/config/config.yml @@ -83,9 +83,9 @@ doctrine: # stores options that change the application behavior and parameters.yml # stores options that change from one server to another # -# swiftmailer: -# transport: "%mailer_transport%" -# host: "%mailer_host%" -# username: "%mailer_user%" -# password: "%mailer_password%" -# spool: { type: memory } +swiftmailer: + transport: "%mailer_transport%" + host: "%mailer_host%" + username: "%mailer_user%" + password: "%mailer_password%" + spool: { type: memory } diff --git a/app/config/config_dev.yml b/app/config/config_dev.yml index ff9c5dfef..b26cb19b9 100644 --- a/app/config/config_dev.yml +++ b/app/config/config_dev.yml @@ -29,5 +29,5 @@ monolog: # type: chromephp # level: info -#swiftmailer: -# delivery_address: me@example.com +swiftmailer: + disable_delivery: true diff --git a/app/config/parameters.yml.dist b/app/config/parameters.yml.dist index 4cc6ec1e3..a50013b68 100644 --- a/app/config/parameters.yml.dist +++ b/app/config/parameters.yml.dist @@ -31,12 +31,9 @@ parameters: # $ php bin/console doctrine:schema:create # $ php bin/console doctrine:fixtures:load - # Uncomment these parameters if your application sends emails: - # - # mailer_transport: smtp - # mailer_host: 127.0.0.1 - # mailer_user: ~ - # mailer_password: ~ - # # If you don't use a real mail server, you can send emails via your Gmail account. # see http://symfony.com/doc/current/cookbook/email/gmail.html + mailer_transport: smtp + mailer_host: 127.0.0.1 + mailer_user: ~ + mailer_password: ~ diff --git a/src/AppBundle/Controller/BlogController.php b/src/AppBundle/Controller/BlogController.php index 3c107b29d..006b2fdd6 100644 --- a/src/AppBundle/Controller/BlogController.php +++ b/src/AppBundle/Controller/BlogController.php @@ -22,6 +22,7 @@ use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\Routing\Generator\UrlGeneratorInterface; /** * Controller used to manage blog contents in the public part of the site. @@ -96,6 +97,8 @@ public function commentNewAction(Request $request, Post $post) $entityManager->persist($comment); $entityManager->flush(); + $this->notifyAuthorAboutNewComment($comment); + return $this->redirectToRoute('blog_post', ['slug' => $post->getSlug()]); } @@ -105,6 +108,33 @@ public function commentNewAction(Request $request, Post $post) ]); } + private function notifyAuthorAboutNewComment(Comment $comment) + { + $post = $comment->getPost(); + + $linkToPost = $this->generateUrl('blog_post', ['slug' => $post->getSlug()], UrlGeneratorInterface::ABSOLUTE_URL); + + $translator = $this->get('translator'); + + $subject = $translator->trans('post.recieved_comment'); + $body = $translator->trans('post.recieved_comment_message', [ + '%title%' => $post->getTitle(), + '%link%' => $linkToPost.'#comment_'.$comment->getId(), + ]); + + // See http://symfony.com/doc/current/email.html#sending-emails + $message = \Swift_Message::newInstance() + ->setSubject($subject) + ->setTo($post->getAuthorEmail()) + ->setFrom('symfony-demo@localhost') + ->setBody($body, 'text/html') + ; + + // You can view a sent email in the debug toolbar + // See http://symfony.com/doc/current/email/dev_environment.html#viewing-from-the-web-debug-toolbar + $this->get('mailer')->send($message); + } + /** * This controller is called directly via the render() function in the * blog/post_show.html.twig template. That's why it's not needed to define From b4a97beb75ec70e536e307388874a82e6b36b64a Mon Sep 17 00:00:00 2001 From: Oleg Voronkovich Date: Sun, 8 Jan 2017 18:04:31 +0300 Subject: [PATCH 02/11] Use event listener and custom event trigger --- app/config/services.yml | 12 ++- src/AppBundle/Controller/BlogController.php | 36 ++------ .../CommentNotificationListener.php | 89 +++++++++++++++++++ src/AppBundle/Events.php | 29 ++++++ 4 files changed, 134 insertions(+), 32 deletions(-) create mode 100644 src/AppBundle/EventListener/CommentNotificationListener.php create mode 100644 src/AppBundle/Events.php diff --git a/app/config/services.yml b/app/config/services.yml index bfe5ee2f7..efc0e9cab 100644 --- a/app/config/services.yml +++ b/app/config/services.yml @@ -31,9 +31,15 @@ services: tags: - { name: kernel.event_listener, event: kernel.request, method: onKernelRequest } - # Event subscribers are similar to event listeners but they don't need to add - # a separate tag for each listened event. Instead, the PHP class of the event - # subscriber includes a method that returns the list of listened events. + app.comment_notification: + class: AppBundle\EventListener\CommentNotificationListener + arguments: ['@mailer', '@router', '@translator', '%app.notifications.email_sender%'] + tags: + - { name: kernel.event_listener, event: comment.created, method: onCommentCreated } + + # Event subscribers are similar to event listeners but they don't need service tags. + # Instead, the PHP class of the event subscriber includes a method that returns + # the list of events listened by that class. # See http://symfony.com/doc/current/event_dispatcher.html#creating-an-event-subscriber app.console_subscriber: class: AppBundle\EventListener\ConsoleEventSubscriber diff --git a/src/AppBundle/Controller/BlogController.php b/src/AppBundle/Controller/BlogController.php index 006b2fdd6..555d77d89 100644 --- a/src/AppBundle/Controller/BlogController.php +++ b/src/AppBundle/Controller/BlogController.php @@ -13,6 +13,7 @@ use AppBundle\Entity\Comment; use AppBundle\Entity\Post; +use AppBundle\Events; use AppBundle\Form\CommentType; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method; @@ -20,9 +21,9 @@ use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security; use Symfony\Bundle\FrameworkBundle\Controller\Controller; +use Symfony\Component\EventDispatcher\GenericEvent; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\Routing\Generator\UrlGeneratorInterface; /** * Controller used to manage blog contents in the public part of the site. @@ -97,7 +98,11 @@ public function commentNewAction(Request $request, Post $post) $entityManager->persist($comment); $entityManager->flush(); - $this->notifyAuthorAboutNewComment($comment); + // See http://symfony.com/doc/current/components/event_dispatcher/generic_event.html + $event = new GenericEvent($comment); + + // See http://symfony.com/doc/current/components/event_dispatcher.html + $this->get('event_dispatcher')->dispatch(Events::COMMENT_CREATED, $event); return $this->redirectToRoute('blog_post', ['slug' => $post->getSlug()]); } @@ -108,33 +113,6 @@ public function commentNewAction(Request $request, Post $post) ]); } - private function notifyAuthorAboutNewComment(Comment $comment) - { - $post = $comment->getPost(); - - $linkToPost = $this->generateUrl('blog_post', ['slug' => $post->getSlug()], UrlGeneratorInterface::ABSOLUTE_URL); - - $translator = $this->get('translator'); - - $subject = $translator->trans('post.recieved_comment'); - $body = $translator->trans('post.recieved_comment_message', [ - '%title%' => $post->getTitle(), - '%link%' => $linkToPost.'#comment_'.$comment->getId(), - ]); - - // See http://symfony.com/doc/current/email.html#sending-emails - $message = \Swift_Message::newInstance() - ->setSubject($subject) - ->setTo($post->getAuthorEmail()) - ->setFrom('symfony-demo@localhost') - ->setBody($body, 'text/html') - ; - - // You can view a sent email in the debug toolbar - // See http://symfony.com/doc/current/email/dev_environment.html#viewing-from-the-web-debug-toolbar - $this->get('mailer')->send($message); - } - /** * This controller is called directly via the render() function in the * blog/post_show.html.twig template. That's why it's not needed to define diff --git a/src/AppBundle/EventListener/CommentNotificationListener.php b/src/AppBundle/EventListener/CommentNotificationListener.php new file mode 100644 index 000000000..b3b292ab8 --- /dev/null +++ b/src/AppBundle/EventListener/CommentNotificationListener.php @@ -0,0 +1,89 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace AppBundle\EventListener; + +use Symfony\Component\EventDispatcher\GenericEvent; +use Symfony\Component\Routing\Generator\UrlGeneratorInterface; +use Symfony\Component\Translation\TranslatorInterface; + +/** + * Notifies post's author about new comments. + * + * @author Oleg Voronkovich + */ +class CommentNotificationListener +{ + /** + * @var \Swift_Mailer + */ + private $mailer; + + /** + * @var TranslatorInterface + */ + private $translator; + + /** + * @var UrlGeneratorInterface + */ + private $urlGenerator; + + /** + * @var string + */ + private $sender = 'symfony-demo@localhost'; + + /** + * Constructor. + * + * @param \Swift_Mailer $mailer + * @param UrlGeneratorInterface $urlGenerator + * @param TranslatorInterface $translator + * @param string|null $sender + */ + public function __construct(\Swift_Mailer $mailer, UrlGeneratorInterface $urlGenerator, TranslatorInterface $translator, $sender = null) + { + $this->mailer = $mailer; + $this->urlGenerator = $urlGenerator; + $this->translator = $translator; + $this->sender = $sender ?: $this->sender; + } + + /** + * @param GenericEvent $event + */ + public function onCommentCreated(GenericEvent $event) + { + $comment = $event->getSubject(); + $post = $comment->getPost(); + + $linkToPost = $this->urlGenerator->generate('blog_post', ['slug' => $post->getSlug()], UrlGeneratorInterface::ABSOLUTE_URL); + + $subject = $this->translator->trans('post.recieved_comment'); + $body = $this->translator->trans('post.recieved_comment_message', [ + '%title%' => $post->getTitle(), + '%link%' => $linkToPost.'#comment_'.$comment->getId(), + ]); + + // See http://symfony.com/doc/current/email.html#sending-emails + $message = \Swift_Message::newInstance() + ->setSubject($subject) + ->setTo($post->getAuthorEmail()) + ->setFrom($this->sender) + ->setBody($body, 'text/html') + ; + + // You can view a sent email in the debug toolbar + // See http://symfony.com/doc/current/email/dev_environment.html#viewing-from-the-web-debug-toolbar + $this->mailer->send($message); + } +} diff --git a/src/AppBundle/Events.php b/src/AppBundle/Events.php new file mode 100644 index 000000000..a120071db --- /dev/null +++ b/src/AppBundle/Events.php @@ -0,0 +1,29 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace AppBundle; + +/** + * Contains all events thrown in the Symfony demo application. + * + * @author Oleg Voronkovich + */ +final class Events +{ + /** + * See http://symfony.com/doc/current/components/event_dispatcher.html#naming-conventions. + * + * @Event("Symfony\Component\EventDispatcher\GenericEvent") + * + * @var string + */ + const COMMENT_CREATED = 'comment.created'; +} From f3b258a55343dc5940e2bb0510b71a3b0640b6a9 Mon Sep 17 00:00:00 2001 From: Oleg Voronkovich Date: Mon, 9 Jan 2017 19:14:41 +0300 Subject: [PATCH 03/11] Remove default value for sender property --- .../EventListener/CommentNotificationListener.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/AppBundle/EventListener/CommentNotificationListener.php b/src/AppBundle/EventListener/CommentNotificationListener.php index b3b292ab8..6fe2f427f 100644 --- a/src/AppBundle/EventListener/CommentNotificationListener.php +++ b/src/AppBundle/EventListener/CommentNotificationListener.php @@ -40,7 +40,7 @@ class CommentNotificationListener /** * @var string */ - private $sender = 'symfony-demo@localhost'; + private $sender; /** * Constructor. @@ -48,14 +48,14 @@ class CommentNotificationListener * @param \Swift_Mailer $mailer * @param UrlGeneratorInterface $urlGenerator * @param TranslatorInterface $translator - * @param string|null $sender + * @param string $sender */ - public function __construct(\Swift_Mailer $mailer, UrlGeneratorInterface $urlGenerator, TranslatorInterface $translator, $sender = null) + public function __construct(\Swift_Mailer $mailer, UrlGeneratorInterface $urlGenerator, TranslatorInterface $translator, $sender) { $this->mailer = $mailer; $this->urlGenerator = $urlGenerator; $this->translator = $translator; - $this->sender = $sender ?: $this->sender; + $this->sender = $sender; } /** From 4125af953f238a6af2079938c50243b78630efac Mon Sep 17 00:00:00 2001 From: Oleg Voronkovich Date: Mon, 9 Jan 2017 19:40:29 +0300 Subject: [PATCH 04/11] Add note about event listener's method --- app/config/services.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/config/services.yml b/app/config/services.yml index efc0e9cab..8122ec9eb 100644 --- a/app/config/services.yml +++ b/app/config/services.yml @@ -34,6 +34,9 @@ services: app.comment_notification: class: AppBundle\EventListener\CommentNotificationListener arguments: ['@mailer', '@router', '@translator', '%app.notifications.email_sender%'] + # There is an optional tag attribute called "method" which defines which method to execute when the event is triggered. + # By default the name of the method is on + "camel-cased event name". + # If the event is "comment.created" the method executed by default is onCommentCreated(). tags: - { name: kernel.event_listener, event: comment.created, method: onCommentCreated } From f37e55280249b2c229d1ee2d5aba16323c15ee35 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Tue, 10 Jan 2017 15:35:11 +0100 Subject: [PATCH 05/11] Minor tweaks in the translation strings --- app/Resources/translations/messages.en.xlf | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/Resources/translations/messages.en.xlf b/app/Resources/translations/messages.en.xlf index 066197d13..9d94ec7c2 100644 --- a/app/Resources/translations/messages.en.xlf +++ b/app/Resources/translations/messages.en.xlf @@ -276,13 +276,13 @@ post.deleted_successfully Post deleted successfully! - - post.recieved_comment - Your post recieved a comment! + + post.comment_added + Your post received a comment! - - post.recieved_comment_message - link!]]> + + post.comment_added.description + this link]]> From ec601b69c2e10557a6dec84f8c4f22e0b996be93 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Tue, 10 Jan 2017 15:44:01 +0100 Subject: [PATCH 06/11] Minor reword in the help note --- app/config/services.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/config/services.yml b/app/config/services.yml index 8122ec9eb..a3c388a99 100644 --- a/app/config/services.yml +++ b/app/config/services.yml @@ -34,9 +34,8 @@ services: app.comment_notification: class: AppBundle\EventListener\CommentNotificationListener arguments: ['@mailer', '@router', '@translator', '%app.notifications.email_sender%'] - # There is an optional tag attribute called "method" which defines which method to execute when the event is triggered. - # By default the name of the method is on + "camel-cased event name". - # If the event is "comment.created" the method executed by default is onCommentCreated(). + # The "method" attribute of this tag is optional and defaults to "on + camelCasedEventName" + # If the event is "comment.created" the method executed by default is "onCommentCreated()". tags: - { name: kernel.event_listener, event: comment.created, method: onCommentCreated } From a59676191b844cd23d20687ad6a43ab6ae7bcbfd Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Tue, 10 Jan 2017 15:55:15 +0100 Subject: [PATCH 07/11] Improved some help notes --- src/AppBundle/Controller/BlogController.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/AppBundle/Controller/BlogController.php b/src/AppBundle/Controller/BlogController.php index 555d77d89..039ce867f 100644 --- a/src/AppBundle/Controller/BlogController.php +++ b/src/AppBundle/Controller/BlogController.php @@ -98,9 +98,17 @@ public function commentNewAction(Request $request, Post $post) $entityManager->persist($comment); $entityManager->flush(); + // When triggering an event, you can optionally pass some information. + // For simple applications, use the GenericEvent object provided by Symfony + // to pass some PHP variables. For more complex applications, define your + // own event object classes. // See http://symfony.com/doc/current/components/event_dispatcher/generic_event.html $event = new GenericEvent($comment); + // When an event is dispatched, Symfony notifies it to all the listeners + // and subscribers registered to it. Listeners can modify the information + // passed in the event and they can even modify the execution flow, so + // there's no guarantee that the rest of this controller will be executed. // See http://symfony.com/doc/current/components/event_dispatcher.html $this->get('event_dispatcher')->dispatch(Events::COMMENT_CREATED, $event); From bbc4077a215e128c9076fecc238f751815dd134a Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Tue, 10 Jan 2017 16:03:39 +0100 Subject: [PATCH 08/11] Improved more help notes --- src/AppBundle/EventListener/CommentNotificationListener.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/AppBundle/EventListener/CommentNotificationListener.php b/src/AppBundle/EventListener/CommentNotificationListener.php index 6fe2f427f..9f0294cf2 100644 --- a/src/AppBundle/EventListener/CommentNotificationListener.php +++ b/src/AppBundle/EventListener/CommentNotificationListener.php @@ -74,6 +74,8 @@ public function onCommentCreated(GenericEvent $event) '%link%' => $linkToPost.'#comment_'.$comment->getId(), ]); + // Symfony uses a library called SwiftMailer to send emails. That's why + // email messages are created instantiating a Swift_Message class. // See http://symfony.com/doc/current/email.html#sending-emails $message = \Swift_Message::newInstance() ->setSubject($subject) @@ -82,7 +84,9 @@ public function onCommentCreated(GenericEvent $event) ->setBody($body, 'text/html') ; - // You can view a sent email in the debug toolbar + // In app/config/config_dev.yml the 'disable_delivery' option is set to 'true'. + // That's why in the development environment you won't actually receive any email. + // However, you can inspect the contents of those unsent emails using the debug toolbar. // See http://symfony.com/doc/current/email/dev_environment.html#viewing-from-the-web-debug-toolbar $this->mailer->send($message); } From 1e83a1df6badd514ef1dc41b0001010f1232fb7b Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Tue, 10 Jan 2017 16:13:00 +0100 Subject: [PATCH 09/11] Final round of help notes improvements --- src/AppBundle/Events.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/AppBundle/Events.php b/src/AppBundle/Events.php index a120071db..cc504a092 100644 --- a/src/AppBundle/Events.php +++ b/src/AppBundle/Events.php @@ -12,14 +12,17 @@ namespace AppBundle; /** - * Contains all events thrown in the Symfony demo application. + * This class defines the names of all the events dispatched in + * the Symfony Demo application. It's not mandatory to create a + * class like this, but it's considered a good practice. * * @author Oleg Voronkovich */ final class Events { /** - * See http://symfony.com/doc/current/components/event_dispatcher.html#naming-conventions. + * For the event naming conventions, see: + * http://symfony.com/doc/current/components/event_dispatcher.html#naming-conventions. * * @Event("Symfony\Component\EventDispatcher\GenericEvent") * From f9189569615991a7f45767b7daef051aece0adf2 Mon Sep 17 00:00:00 2001 From: Oleg Voronkovich Date: Tue, 10 Jan 2017 20:38:11 +0300 Subject: [PATCH 10/11] Use '_fragment' parameter --- .../EventListener/CommentNotificationListener.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/AppBundle/EventListener/CommentNotificationListener.php b/src/AppBundle/EventListener/CommentNotificationListener.php index 9f0294cf2..ccf9c0874 100644 --- a/src/AppBundle/EventListener/CommentNotificationListener.php +++ b/src/AppBundle/EventListener/CommentNotificationListener.php @@ -66,12 +66,15 @@ public function onCommentCreated(GenericEvent $event) $comment = $event->getSubject(); $post = $comment->getPost(); - $linkToPost = $this->urlGenerator->generate('blog_post', ['slug' => $post->getSlug()], UrlGeneratorInterface::ABSOLUTE_URL); + $linkToPost = $this->urlGenerator->generate('blog_post', [ + 'slug' => $post->getSlug(), + '_fragment' => 'comment_'.$comment->getId(), + ], UrlGeneratorInterface::ABSOLUTE_URL); - $subject = $this->translator->trans('post.recieved_comment'); - $body = $this->translator->trans('post.recieved_comment_message', [ + $subject = $this->translator->trans('post.comment_added'); + $body = $this->translator->trans('post.comment_added.description', [ '%title%' => $post->getTitle(), - '%link%' => $linkToPost.'#comment_'.$comment->getId(), + '%link%' => $linkToPost, ]); // Symfony uses a library called SwiftMailer to send emails. That's why From 7dc958ca93e4eda92d887a0aa0655c752745cd15 Mon Sep 17 00:00:00 2001 From: Oleg Voronkovich Date: Tue, 10 Jan 2017 22:21:50 +0300 Subject: [PATCH 11/11] Change prefix for translation messages --- app/Resources/translations/messages.en.xlf | 9 +++++---- .../EventListener/CommentNotificationListener.php | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/Resources/translations/messages.en.xlf b/app/Resources/translations/messages.en.xlf index 9d94ec7c2..b01531891 100644 --- a/app/Resources/translations/messages.en.xlf +++ b/app/Resources/translations/messages.en.xlf @@ -276,12 +276,13 @@ post.deleted_successfully Post deleted successfully! - - post.comment_added + + + notification.comment_created Your post received a comment! - - post.comment_added.description + + notification.comment_created.description this link]]> diff --git a/src/AppBundle/EventListener/CommentNotificationListener.php b/src/AppBundle/EventListener/CommentNotificationListener.php index ccf9c0874..ff28cae0a 100644 --- a/src/AppBundle/EventListener/CommentNotificationListener.php +++ b/src/AppBundle/EventListener/CommentNotificationListener.php @@ -71,8 +71,8 @@ public function onCommentCreated(GenericEvent $event) '_fragment' => 'comment_'.$comment->getId(), ], UrlGeneratorInterface::ABSOLUTE_URL); - $subject = $this->translator->trans('post.comment_added'); - $body = $this->translator->trans('post.comment_added.description', [ + $subject = $this->translator->trans('notification.comment_created'); + $body = $this->translator->trans('notification.comment_created.description', [ '%title%' => $post->getTitle(), '%link%' => $linkToPost, ]);