Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/Symfony/Bridge/Twig/Mime/NotificationEmail.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,15 +210,20 @@ private function getExceptionAsString($exception): string
*/
public function __serialize(): array
{
return [$this->context, parent::__serialize()];
return [$this->context, $this->theme, parent::__serialize()];
}

/**
* @internal
*/
public function __unserialize(array $data): void
{
[$this->context, $parentData] = $data;
if (3 === \count($data)) {
[$this->context, $this->theme, $parentData] = $data;
} else {
// Backwards compatibility for deserializing data structures that were serialized without the theme
[$this->context, $parentData] = $data;
}

parent::__unserialize($parentData);
}
Expand Down
3 changes: 3 additions & 0 deletions src/Symfony/Bridge/Twig/Tests/Mime/NotificationEmailTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public function testSerialize()
->importance(NotificationEmail::IMPORTANCE_HIGH)
->action('Bar', 'http://example.com/')
->context(['a' => 'b'])
->theme('example')
));
$this->assertEquals([
'importance' => NotificationEmail::IMPORTANCE_HIGH,
Expand All @@ -57,6 +58,8 @@ public function testSerialize()
'raw' => true,
'a' => 'b',
], $email->getContext());

$this->assertSame('@email/example/notification/body.html.twig', $email->getHtmlTemplate());
}

public function testTheme()
Expand Down