You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When attempting to add to the context of the NotificationEmail using getContext() and calling NotificationEmail::action(...) the action context values are never set due to the usage of return array_merge($this->context, parent::getContext()) and calling ::context() is applied to the parent TemplatedEmail.
How to reproduce
$notification = newNotificationEmail();
$notification->context(['some' => 'context']);
/** * ... do other things like pass to a handler/dispatcher/listener */$context = $notification->getContext();
$context['foo'] = 'bar';
$notification->context($context);
$notification->action('Action Text', 'Action URL');
dump($notification->getContext());
Discovered when attempting to make a notification handler that would add to the email context and call the NotificationEmail::action(). When dumping the object it showed the action context keys as being set, but the actions were not in the generated content, which was unexpected behavior.
dump($notification);
Result
The text was updated successfully, but these errors were encountered:
…tionEmail on writes (xabbuh)
This PR was merged into the 5.4 branch.
Discussion
----------
[TwigBridge] separate child and parent context in NotificationEmail on writes
| Q | A
| ------------- | ---
| Branch? | 5.4
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Issues | Fix#53655
| License | MIT
Commits
-------
78bbfb0 separate child and parent context in NotificationEmail on writes
Symfony version(s) affected
4.4, 5,4, 6.4, 7.0
Description
When attempting to add to the context of the
NotificationEmail
usinggetContext()
and callingNotificationEmail::action(...)
the action context values are never set due to the usage ofreturn array_merge($this->context, parent::getContext())
and calling::context()
is applied to the parentTemplatedEmail
.How to reproduce
Result
Generic Example of the issue: https://3v4l.org/InQVh
Possible Solution
Workaround
Call
NotificationEmail::action()
prior toNotificationEmail::getContext()
.Additional Context
Discovered when attempting to make a notification handler that would add to the email context and call the
NotificationEmail::action()
. When dumping the object it showed the action context keys as being set, but the actions were not in the generated content, which was unexpected behavior.Result
The text was updated successfully, but these errors were encountered: