[twig-bridge] Allow NotificationEmail to be marked as public
This commit is contained in:
parent
906b609d0e
commit
8f753d27f2
@ -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
|
||||
-----
|
||||
|
||||
|
@ -64,12 +64,19 @@ class NotificationEmail extends TemplatedEmail
|
||||
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
|
||||
*/
|
||||
|
@ -85,6 +85,25 @@ class NotificationEmailTest extends TestCase
|
||||
'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()
|
||||
@ -92,5 +111,9 @@ class NotificationEmailTest extends TestCase
|
||||
$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());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user