MailSentEvent example

use Shopware\Core\Framework\Context;

/** * @internal * * @covers \Shopware\Core\Content\MailTemplate\Service\Event\MailSentEvent */
class MailSentEventTest extends TestCase
{
    public function testScalarValuesCorrectly(): void
    {
        $event = new MailSentEvent(
            'my-subject',
            ['foo' => 'bar'],
            ['mixed' => 'content'],
            Context::createDefaultContext()
        );

        $storer = new ScalarValuesStorer();

        $stored = $storer->store($event[]);

        $flow = new StorableFlow('foo', Context::createDefaultContext()$stored);

        


        $event = new MailBeforeSentEvent($data$mail$context$templateData['eventName'] ?? null);
        $this->eventDispatcher->dispatch($event);

        if ($event->isPropagationStopped()) {
            return null;
        }

        $this->mailSender->send($mail);

        $event = new MailSentEvent($data['subject']$recipients$contents$context$templateData['eventName'] ?? null);
        $this->eventDispatcher->dispatch($event);

        return $mail;
    }

    /** * @param mixed[] $data */
    private function getSender(array $data, ?string $salesChannelId): ?string
    {
        $senderEmail = $data['senderEmail'] ?? null;

        
Home | Imprint | This part of the site doesn't use cookies.