8000 Added possiblity to create a 'public notification email' · symfony/symfony@bfa520e · GitHub
[go: up one dir, main page]

Skip to content

Commit bfa520e

Browse files
committed
Added possiblity to create a 'public notification email'
This removes the "notification send by Symfony" and importance levels
1 parent ffbb988 commit bfa520e

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

src/Symfony/Bridge/Twig/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ CHANGELOG
1010
* added the `t()` function to easily create `TranslatableMessage` objects
1111
* Added support for extracting messages from the `t()` function
1212
* Added `field_*` Twig functions to access string values from Form fields
13+
* changed the `importance` context option of `NotificationEmail` to allow `null`
1314

1415
5.0.0
1516
-----

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

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class NotificationEmail extends TemplatedEmail
3737
'action_url' => null,
3838
'markdown' => false,
3939
'raw' => false,
40+
'show_footer' => true,
4041
];
4142

4243
public function __construct(Headers $headers = null, AbstractPart $body = null)
@@ -57,6 +58,19 @@ public function __construct(Headers $headers = null, AbstractPart $body = null)
5758
parent::__construct($headers, $body);
5859
}
5960

61+
/**
62+
* Creates a NotificationEmail instance that can be used to sent
63+
* normal emails to users.
64+
*/
65+
public static function asPublicEmail(Headers $headers = null, AbstractPart $body = null): self
66+
{
67+
$email = new static($headers, $body);
68+
$email->context['importance'] = null;
69+
$email->context['show_footer'] = false;
70+
71+
return $email;
72+
}
73+
6074
/**
6175
* @return $this
6276
*/
@@ -166,7 +180,9 @@ public function getPreparedHeaders(): Headers
166180

167181
$importance = $this->context['importance'] ?? self::IMPORTANCE_LOW;
168182
$this->priority($this->determinePriority($importance));
169-
$headers->setHeaderBody('Text', 'Subject', sprintf('[%s] %s', strtoupper($importance), $this->getSubject()));
183+
if ($this->context['importance']) {
184+
$headers->setHeaderBody('Text', 'Subject', sprintf('[%s] %s', strtoupper($importance), $this->getSubject()));
185+
}
170186

171187
return $headers;
172188
}

src/Symfony/Bridge/Twig/Resources/views/Email/zurb_2/notification/body.html.twig

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<row>
1717
<columns large="12" small="12">
1818
{% block lead %}
19-
<small><strong>{{ importance|upper }}</strong></small>
19+
{% if importance %}<small><strong>{{ importance|upper }}</strong></small>{% endif %}
2020
<p class="lead">
2121
{{ email.subject }}
2222
</p>
@@ -49,13 +49,15 @@
4949
<wrapper class="secondary">
5050
<spacer size="16"></spacer>
5151
{% block footer %}
52+
{% if show_footer is not defined or show_footer %}
5253
<row>
5354
<columns small="12" large="6">
5455
{% block footer_content %}
5556
<p><small>Notification e-mail sent by Symfony</small></p>
5657
{% endblock %}
5758
</columns>
5859
</row>
60+
{% endif %}
5961
{% endblock %}
6062
</wrapper>
6163
</container>

0 commit comments

Comments
 (0)
0