From cdcb5c872cf4de18dc66ff6868b91cc006f520b4 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Sun, 3 Sep 2017 10:28:47 +0200 Subject: [PATCH 1/2] fix flash message generation --- service_container.rst | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/service_container.rst b/service_container.rst index b1e37cdc78a..5bce0e0c26a 100644 --- a/service_container.rst +++ b/service_container.rst @@ -366,8 +366,6 @@ made. To do that, you create a new class:: 'Someone just updated the site. We told them: '.$happyMessage ); $this->mailer->send($message); - - return $happyMessage; } } @@ -381,8 +379,8 @@ you can use the service immediately:: { // ... - $message = $siteUpdateManager->notifyOfSiteUpdate(); - $this->addFlash('success', $message); + $siteUpdateManager->notifyOfSiteUpdate(); + $this->addFlash('success', 'Notification mail was sent successfully.'); // ... } From cba04784e7ca86900e1f20592981f5d9b1489eea Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 4 Jan 2018 11:46:46 +0100 Subject: [PATCH 2/2] Refactored the code --- service_container.rst | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/service_container.rst b/service_container.rst index 5bce0e0c26a..401a93199b6 100644 --- a/service_container.rst +++ b/service_container.rst @@ -365,7 +365,8 @@ made. To do that, you create a new class:: ->addPart( 'Someone just updated the site. We told them: '.$happyMessage ); - $this->mailer->send($message); + + return $this->mailer->send($message) > 0; } } @@ -379,8 +380,10 @@ you can use the service immediately:: { // ... - $siteUpdateManager->notifyOfSiteUpdate(); - $this->addFlash('success', 'Notification mail was sent successfully.'); + if ($siteUpdateManager->notifyOfSiteUpdate()) { + $this->addFlash('success', 'Notification mail was sent successfully.'); + } + // ... }