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

[twig-bridge] Allow NotificationEmail to be marked as public #40448

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 12, 2021
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
5 changes: 5 additions & 0 deletions 5 src/Symfony/Bridge/Twig/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
CHANGELOG
=========

5.3
-----

* Add a new `markAsPublic` method on `NotificationEmail` to change the `importance` context option to null after creation

5.3.0
-----

Expand Down
11 changes: 9 additions & 2 deletions 11 src/Symfony/Bridge/Twig/Mime/NotificationEmail.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,19 @@ public function __construct(Headers $headers = null, AbstractPart $body = null)
public static function asPublicEmail(Headers $headers = null, AbstractPart $body = null): self
{
$email = new static($headers, $body);
$email->context['importance'] = null;
$email->context['footer_text'] = null;
$email->markAsPublic();

return $email;
}

public function markAsPublic(): self
{
$this->context['importance'] = null;
$this->context['footer_text'] = null;

return $this;
}

/**
* @return $this
*/
Expand Down
23 changes: 23 additions & 0 deletions 23 src/Symfony/Bridge/Twig/Tests/Mime/NotificationEmailTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,35 @@ public function testPublicMail()
'a' => 'b',
'footer_text' => null,
], $email->getContext());

$email = (new NotificationEmail())
->markAsPublic()
->markdown('Foo')
->action('Bar', 'http://example.com/')
->context(['a' => 'b'])
;

$this->assertEquals([
'importance' => null,
'content' => 'Foo',
'exception' => false,
'action_text' => 'Bar',
'action_url' => 'http://example.com/',
'markdown' => true,
'raw' => false,
'a' => 'b',
'footer_text' => null,
], $email->getContext());
}

public function testPublicMailSubject()
{
$email = NotificationEmail::asPublicEmail()->from('me@example.com')->subject('Foo');
$headers = $email->getPreparedHeaders();
$this->assertSame('Foo', $headers->get('Subject')->getValue());

$email = (new NotificationEmail())->markAsPublic()->from('me@example.com')->subject('Foo');
$headers = $email->getPreparedHeaders();
$this->assertSame('Foo', $headers->get('Subject')->getValue());
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.