From cedb7cc28d4b2b9b8a1c2421e689a759f6f2f6a8 Mon Sep 17 00:00:00 2001 From: Matthias Krauser Date: Fri, 24 Nov 2023 15:50:44 +0100 Subject: [PATCH] [Mime] Add `TemplatedEmail::$locale` to the serialized props --- src/Symfony/Bridge/Twig/Mime/TemplatedEmail.php | 3 ++- src/Symfony/Bridge/Twig/Tests/Mime/TemplatedEmailTest.php | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bridge/Twig/Mime/TemplatedEmail.php b/src/Symfony/Bridge/Twig/Mime/TemplatedEmail.php index e5c990f3ba733..2d308947f8498 100644 --- a/src/Symfony/Bridge/Twig/Mime/TemplatedEmail.php +++ b/src/Symfony/Bridge/Twig/Mime/TemplatedEmail.php @@ -100,7 +100,7 @@ public function markAsRendered(): void */ public function __serialize(): array { - return [$this->htmlTemplate, $this->textTemplate, $this->context, parent::__serialize()]; + return [$this->htmlTemplate, $this->textTemplate, $this->context, parent::__serialize(), $this->locale]; } /** @@ -109,6 +109,7 @@ public function __serialize(): array public function __unserialize(array $data): void { [$this->htmlTemplate, $this->textTemplate, $this->context, $parentData] = $data; + $this->locale = $data[4] ?? null; parent::__unserialize($parentData); } diff --git a/src/Symfony/Bridge/Twig/Tests/Mime/TemplatedEmailTest.php b/src/Symfony/Bridge/Twig/Tests/Mime/TemplatedEmailTest.php index f796c7a05db7e..81f0edb6870ea 100644 --- a/src/Symfony/Bridge/Twig/Tests/Mime/TemplatedEmailTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Mime/TemplatedEmailTest.php @@ -43,12 +43,14 @@ public function testSerialize() ->textTemplate('text.txt.twig') ->htmlTemplate('text.html.twig') ->context($context = ['a' => 'b']) + ->locale($locale = 'fr_FR') ; $email = unserialize(serialize($email)); $this->assertEquals('text.txt.twig', $email->getTextTemplate()); $this->assertEquals('text.html.twig', $email->getHtmlTemplate()); $this->assertEquals($context, $email->getContext()); + $this->assertEquals($locale, $email->getLocale()); } public function testSymfonySerialize()