Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Mailer][Profiler] 6.2-dev Email context is empty message collected form Profiler #47993

Closed
@silverbackdan

Description

@silverbackdan

Symfony version(s) affected

6.2-dev

Description

I test in my project that the context of the email has got the correct variables being set. But in 6.2 the message collected by the profiler now has an empty context.

How to reproduce

In my case website_name is being set.

I create the email like so:

$email = (new TemplatedEmail())
            ->to($toEmailAddress)
            ->subject($subject)
            ->htmlTemplate('@SilverbackApiComponents/emails/' . $this->getTemplate())
            ->context($context);

$context is:

array:2 [
  "user" => 'xxx'
  "website_name" => "New Website"
]

I collect the email and context from the profiler in my test:

** @var MessageDataCollector $collector */
        $collector = $this->getProfile()->getCollector('mailer');
        /** @var TemplatedEmail[] $messages */
        $messages = $collector->getEvents()->getMessages();

        Assert::assertCount(1, $messages);
        Assert::assertInstanceOf(TemplatedEmail::class, $email = $messages[0]);

        /** @var TemplatedEmail $email */
        $context = $email->getContext();

And in 6.2 beta, the context is an empty array.

Possible Solution

No response

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions