Skip to content

Commit

Permalink
Listener Request Bug Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
cesurapp committed Sep 18, 2020
1 parent cceba36 commit 061f0e2
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Mailer/Listener.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ private function addLog(Email $email): void
{
// Get Template ID
$template = $email->getHeaders()->get('template');
$locale = $email->getHeaders()->get('locale')->getBodyAsString();

// Create Log
$log = new MailLog();
Expand All @@ -97,7 +98,7 @@ private function addLog(Email $email): void
->setSubject($email->getSubject())
->setBody(\is_array($email->getHtmlBody()) ? $email->getHtmlBody() : [])
->setDate(new \DateTime())
->setLanguage($this->request->getCurrentRequest()->getLocale() ?? 'en')
->setLanguage($locale ?? ($this->request->getCurrentRequest() ? $this->request->getCurrentRequest()->getLocale() : 'en'))
->setTemplateId($template ? $template->getBodyAsString() : '');

// Save
Expand All @@ -112,7 +113,7 @@ private function renderTemplate(Email $email): void
{
if ($templateId = $email->getHeaders()->get('template')) {
$bodyData = $email->getHtmlBody();
$locale = $this->request->getCurrentRequest()->getLocale();
$locale = $email->getHeaders()->get('locale')->getBodyAsString();

// Check Array
if (\is_array($bodyData)) {
Expand All @@ -121,7 +122,7 @@ private function renderTemplate(Email $email): void
->findOneBy([
'templateId' => $templateId->getBody(),
'status' => true,
'language' => $locale,
'language' => $locale ?? ($this->request->getCurrentRequest() ? $this->request->getCurrentRequest()->getLocale() : 'en'),
]);

if ($template) {
Expand Down

0 comments on commit 061f0e2

Please sign in to comment.