Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8f753d2

Browse filesBrowse files
maxailloudfabpot
authored andcommitted
[twig-bridge] Allow NotificationEmail to be marked as public
1 parent 906b609 commit 8f753d2
Copy full SHA for 8f753d2

File tree

3 files changed

+37
-2
lines changed
Filter options

3 files changed

+37
-2
lines changed

‎src/Symfony/Bridge/Twig/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/CHANGELOG.md
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
5.3
5+
-----
6+
7+
* Add a new `markAsPublic` method on `NotificationEmail` to change the `importance` context option to null after creation
8+
49
5.3.0
510
-----
611

‎src/Symfony/Bridge/Twig/Mime/NotificationEmail.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Mime/NotificationEmail.php
+9-2Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,19 @@ public function __construct(Headers $headers = null, AbstractPart $body = null)
6464
public static function asPublicEmail(Headers $headers = null, AbstractPart $body = null): self
6565
{
6666
$email = new static($headers, $body);
67-
$email->context['importance'] = null;
68-
$email->context['footer_text'] = null;
67+
$email->markAsPublic();
6968

7069
return $email;
7170
}
7271

72+
public function markAsPublic(): self
73+
{
74+
$this->context['importance'] = null;
75+
$this->context['footer_text'] = null;
76+
77+
return $this;
78+
}
79+
7380
/**
7481
* @return $this
7582
*/

‎src/Symfony/Bridge/Twig/Tests/Mime/NotificationEmailTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Tests/Mime/NotificationEmailTest.php
+23Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,35 @@ public function testPublicMail()
8585
'a' => 'b',
8686
'footer_text' => null,
8787
], $email->getContext());
88+
89+
$email = (new NotificationEmail())
90+
->markAsPublic()
91+
->markdown('Foo')
92+
->action('Bar', 'http://example.com/')
93+
->context(['a' => 'b'])
94+
;
95+
96+
$this->assertEquals([
97+
'importance' => null,
98+
'content' => 'Foo',
99+
'exception' => false,
100+
'action_text' => 'Bar',
101+
'action_url' => 'http://example.com/',
102+
'markdown' => true,
103+
'raw' => false,
104+
'a' => 'b',
105+
'footer_text' => null,
106+
], $email->getContext());
88107
}
89108

90109
public function testPublicMailSubject()
91110
{
92111
$email = NotificationEmail::asPublicEmail()->from('me@example.com')->subject('Foo');
93112
$headers = $email->getPreparedHeaders();
94113
$this->assertSame('Foo', $headers->get('Subject')->getValue());
114+
115+
$email = (new NotificationEmail())->markAsPublic()->from('me@example.com')->subject('Foo');
116+
$headers = $email->getPreparedHeaders();
117+
$this->assertSame('Foo', $headers->get('Subject')->getValue());
95118
}
96119
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.