[twig-bridge] Allow NotificationEmail to be marked as public
This commit is contained in:
parent
906b609d0e
commit
8f753d27f2
@ -1,6 +1,11 @@
|
|||||||
CHANGELOG
|
CHANGELOG
|
||||||
=========
|
=========
|
||||||
|
|
||||||
|
5.3
|
||||||
|
-----
|
||||||
|
|
||||||
|
* Add a new `markAsPublic` method on `NotificationEmail` to change the `importance` context option to null after creation
|
||||||
|
|
||||||
5.3.0
|
5.3.0
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
@ -64,12 +64,19 @@ class NotificationEmail extends TemplatedEmail
|
|||||||
public static function asPublicEmail(Headers $headers = null, AbstractPart $body = null): self
|
public static function asPublicEmail(Headers $headers = null, AbstractPart $body = null): self
|
||||||
{
|
{
|
||||||
$email = new static($headers, $body);
|
$email = new static($headers, $body);
|
||||||
$email->context['importance'] = null;
|
$email->markAsPublic();
|
||||||
$email->context['footer_text'] = null;
|
|
||||||
|
|
||||||
return $email;
|
return $email;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function markAsPublic(): self
|
||||||
|
{
|
||||||
|
$this->context['importance'] = null;
|
||||||
|
$this->context['footer_text'] = null;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
|
@ -85,6 +85,25 @@ class NotificationEmailTest extends TestCase
|
|||||||
'a' => 'b',
|
'a' => 'b',
|
||||||
'footer_text' => null,
|
'footer_text' => null,
|
||||||
], $email->getContext());
|
], $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()
|
public function testPublicMailSubject()
|
||||||
@ -92,5 +111,9 @@ class NotificationEmailTest extends TestCase
|
|||||||
$email = NotificationEmail::asPublicEmail()->from('me@example.com')->subject('Foo');
|
$email = NotificationEmail::asPublicEmail()->from('me@example.com')->subject('Foo');
|
||||||
$headers = $email->getPreparedHeaders();
|
$headers = $email->getPreparedHeaders();
|
||||||
$this->assertSame('Foo', $headers->get('Subject')->getValue());
|
$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