Skip to content

Commit

Permalink
[WIP][Mailer] Overwrite envelope sender and recipients from config
Browse files Browse the repository at this point in the history
  • Loading branch information
Devristo committed Jun 11, 2019
1 parent ac1a660 commit f023514
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1525,6 +1525,22 @@ private function addMailerSection(ArrayNodeDefinition $rootNode)
->{!class_exists(FullStack::class) && class_exists(Mailer::class) ? 'canBeDisabled' : 'canBeEnabled'}()
->children()
->scalarNode('dsn')->defaultValue('smtp://null')->end()
->arrayNode('envelope')
->info('Mailer Envelope configuration')
->children()
->scalarNode('sender')->end()
->arrayNode('recipients')
->performNoDeepMerging()
->beforeNormalization()
->ifArray()
->then(function ($v) {
return array_filter(array_values($v));
})
->end()
->prototype('scalar')->end()
->end()
->end()
->end()
->end()
->end()
->end()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1917,6 +1917,13 @@ private function registerMailerConfiguration(array $config, ContainerBuilder $co

$loader->load('mailer.xml');
$container->getDefinition('mailer.default_transport')->setArgument(0, $config['dsn']);

$recipients = $config['envelope']['recipients'] ?? null;
$sender = $config['envelope']['sender'] ?? null;

$envelopeListener = $container->getDefinition('mailer.envelope_listener');
$envelopeListener->setArgument(0, $sender);
$envelopeListener->setArgument(1, $recipients);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,11 @@
<argument type="service" id="mailer.default_transport" />
<tag name="messenger.message_handler" />
</service>

<service id="mailer.envelope_listener" class="Symfony\Component\Mailer\EventListener\EnvelopeListener">
<argument>null</argument>
<argument>null</argument>
<tag name="kernel.event_subscriber"/>
</service>
</services>
</container>

0 comments on commit f023514

Please sign in to comment.