Skip to content

Commit

Permalink
[Mime] Add TemplatedEmail::$locale to the serialized props
Browse files Browse the repository at this point in the history
  • Loading branch information
mkrauser authored and fabpot committed Nov 25, 2023
1 parent b85a083 commit cedb7cc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Symfony/Bridge/Twig/Mime/TemplatedEmail.php
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}

/**
Expand All @@ -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);
}
Expand Down
2 changes: 2 additions & 0 deletions src/Symfony/Bridge/Twig/Tests/Mime/TemplatedEmailTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit cedb7cc

Please sign in to comment.