Skip to content

Commit 46a0a7a

Browse files
Merge branch '6.3' into 6.4
* 6.3: Add missing return type [HttpClient] Fix pausing responses before they start when using curl separate child and parent context in NotificationEmail on writes [Mailer] [Mailgun] Fix sender header encoding do not overwrite the cache key when it is false [Mailer] Throw TransportException when unable to read from socket [Serializer] Rewrite `AbstractObjectNormalizer::createChildContext()` to use the provided `cache_key` from original context when creating child contexts [HttpClient] Fix error chunk creation in passthru Adjusting and removing the 'review' attribute from the pt_br translation XML. [Serializer] Take unnamed variadic parameters into account when denormalizing Fix context data and display extra data
2 parents 935cb2c + cdaa2d9 commit 46a0a7a

File tree

2 files changed

+70
-0
lines changed

2 files changed

+70
-0
lines changed

Mime/NotificationEmail.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,26 @@ public function getHtmlTemplate(): ?string
174174
return '@email/'.$this->theme.'/notification/body.html.twig';
175175
}
176176

177+
/**
178+
* @return $this
179+
*/
180+
public function context(array $context): static
181+
{
182+
$parentContext = [];
183+
184+
foreach ($context as $key => $value) {
185+
if (\array_key_exists($key, $this->context)) {
186+
$this->context[$key] = $value;
187+
} else {
188+
$parentContext[$key] = $value;
189+
}
190+
}
191+
192+
parent::context($parentContext);
193+
194+
return $this;
195+
}
196+
177197
public function getContext(): array
178198
{
179199
return array_merge($this->context, parent::getContext());

Tests/Mime/NotificationEmailTest.php

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,4 +128,54 @@ public function testPublicMailSubject()
128128
$headers = $email->getPreparedHeaders();
129129
$this->assertSame('Foo', $headers->get('Subject')->getValue());
130130
}
131+
132+
public function testContext()
133+
{
134+
$email = new NotificationEmail();
135+
$email->context(['some' => 'context']);
136+
137+
$this->assertSame([
138+
'importance' => NotificationEmail::IMPORTANCE_LOW,
139+
'content' => '',
140+
'exception' => false,
141+
'action_text' => null,
142+
'action_url' => null,
143+
'markdown' => false,
144+
'raw' => false,
145+
'footer_text' => 'Notification e-mail sent by Symfony',
146+
'some' => 'context',
147+
], $email->getContext());
148+
149+
$context = $email->getContext();
150+
$context['foo'] = 'bar';
151+
$email->context($context);
152+
153+
$this->assertSame([
154+
'importance' => NotificationEmail::IMPORTANCE_LOW,
155+
'content' => '',
156+
'exception' => false,
157+
'action_text' => null,
158+
'action_url' => null,
159+
'markdown' => false,
160+
'raw' => false,
161+
'footer_text' => 'Notification e-mail sent by Symfony',
162+
'some' => 'context',
163+
'foo' => 'bar',
164+
], $email->getContext());
165+
166+
$email->action('Action Text', 'Action URL');
167+
168+
$this->assertSame([
169+
'importance' => NotificationEmail::IMPORTANCE_LOW,
170+
'content' => '',
171+
'exception' => false,
172+
'action_text' => 'Action Text',
173+
'action_url' => 'Action URL',
174+
'markdown' => false,
175+
'raw' => false,
176+
'footer_text' => 'Notification e-mail sent by Symfony',
177+
'some' => 'context',
178+
'foo' => 'bar',
179+
], $email->getContext());
180+
}
131181
}

0 commit comments

Comments
 (0)