From 4cf6483798d2a2ffbfff553bfabee88a0a85e3a6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micka=C3=ABl=20WLODARCZYK?= <mwl@atolcd.com>
Date: Mon, 6 Jul 2020 11:50:24 +0200
Subject: [PATCH] =?UTF-8?q?Fix=20#64=20:=20Changement=20du=20titre=20du=20?=
 =?UTF-8?q?mail=20envoy=C3=A9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Change-Id: Ieadd06d9ec6e1a9477e9b0652ad85da47da1b6e3
---
 appli_sf/src/Controller/SearchController.php | 30 ++++++++++++++------
 appli_sf/translations/messages.fr.yaml       |  5 ++--
 2 files changed, 24 insertions(+), 11 deletions(-)

diff --git a/appli_sf/src/Controller/SearchController.php b/appli_sf/src/Controller/SearchController.php
index 957760e..da92e97 100644
--- a/appli_sf/src/Controller/SearchController.php
+++ b/appli_sf/src/Controller/SearchController.php
@@ -351,15 +351,27 @@ class SearchController extends BaseController
         /** @var User $user */
         $user = $this->getUser();
 
-        $mailSubject = $this->translator->trans(
-            'searchResultMail.subject.default',
-            [
-                '%appName%'   => $this->settingsData->getAppName(),
-                '%recipient%' => $searchData->getRecipient(),
-                '%firstName%' => $searchData->getFirstName(),
-                '%name%'      => $searchData->getName($this->settingsData),
-            ]
-        );
+        if ($searchData->getRecipient()) {
+            $mailSubject = $this->translator->trans(
+                'searchResultMail.subject.default',
+                [
+                    '%appName%' => $this->settingsData->getAppName(),
+                    '%recipient%' => $searchData->getRecipient(),
+                    '%firstName%' => $searchData->getFirstName(),
+                    '%name%' => $searchData->getName($this->settingsData),
+                ]
+            );
+        } else {
+            $mailSubject = $this->translator->trans(
+                'searchResultMail.subject.norecipient',
+                [
+                    '%appName%' => $this->settingsData->getAppName(),
+                    '%firstName%' => $searchData->getFirstName(),
+                    '%name%' => $searchData->getName($this->settingsData),
+                ]
+            );
+        }
+
         $mailTemplate = '';
         $mailParameters = [
             'firstName'       => $searchData->getFirstName(),
diff --git a/appli_sf/translations/messages.fr.yaml b/appli_sf/translations/messages.fr.yaml
index 53e9428..8346e1a 100644
--- a/appli_sf/translations/messages.fr.yaml
+++ b/appli_sf/translations/messages.fr.yaml
@@ -208,8 +208,9 @@ dateJsValidation:
     deathDateAfterdeathCertificateDate: "La date de décès ne peut être postérieure à la date de l'acte."
 searchResultMail:
     subject:
-        default:    "[%appName%] Notaire référent : %recipient% - Succession %firstName% %name%"
-        hasRequest: "[%appName%] Instruction"
+        default:     "[%appName%] Notaire référent : %recipient% - Succession %firstName% %name%"
+        norecipient: "[%appName%] Succession %firstName% %name%"
+        hasRequest:  "[%appName%] Instruction"
 formError:
     date: "Mauvais format de date"
 userLogs:
-- 
GitLab