diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 4a4cbe9b..41cc09b2 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -197,6 +197,7 @@ * - [level]: level name or int value, defaults to DEBUG * - [bubble]: bool, defaults to true * - [headers]: optional array containing additional headers: ['Foo: Bar', '...'] + * - [parameters]: optional array containing additional parameters: ['--for bar', '...'] * * - symfony_mailer: * - from_email: optional if email_prototype is given @@ -429,6 +430,7 @@ public function getConfigTreeBuilder(): TreeBuilder ->fixXmlConfig('tag') ->fixXmlConfig('accepted_level') ->fixXmlConfig('header') + ->fixXmlConfig('parameter') ->canBeUnset(); $handlerNode @@ -976,6 +978,10 @@ private function addMailerSection(ArrayNodeDefinition $handerNode) ->canBeUnset() ->scalarPrototype()->end() ->end() + ->arrayNode('parameters') // native_mailer + ->canBeUnset() + ->scalarPrototype()->end() + ->end() ->scalarNode('mailer')->defaultNull()->end() // swift_mailer and symfony_mailer ->arrayNode('email_prototype') // swift_mailer and symfony_mailer ->canBeUnset() diff --git a/DependencyInjection/MonologExtension.php b/DependencyInjection/MonologExtension.php index a20b558a..df012e12 100644 --- a/DependencyInjection/MonologExtension.php +++ b/DependencyInjection/MonologExtension.php @@ -576,6 +576,9 @@ private function buildHandler(ContainerBuilder $container, $name, array $handler if (!empty($handler['headers'])) { $definition->addMethodCall('addHeader', [$handler['headers']]); } + if (!empty($handler['parameters'])) { + $definition->addMethodCall('addParameter', [$handler['parameters']]); + } break; case 'symfony_mailer': diff --git a/Resources/config/schema/monolog-1.0.xsd b/Resources/config/schema/monolog-1.0.xsd index b00e969e..8f7b5cf5 100644 --- a/Resources/config/schema/monolog-1.0.xsd +++ b/Resources/config/schema/monolog-1.0.xsd @@ -29,6 +29,7 @@ + diff --git a/Tests/DependencyInjection/FixtureMonologExtensionTest.php b/Tests/DependencyInjection/FixtureMonologExtensionTest.php index 72bc46c5..650f4a8b 100644 --- a/Tests/DependencyInjection/FixtureMonologExtensionTest.php +++ b/Tests/DependencyInjection/FixtureMonologExtensionTest.php @@ -306,8 +306,9 @@ public function testNativeMailer() $logger = $container->getDefinition('monolog.handler.mailer'); $methodCalls = $logger->getMethodCalls(); - $this->assertCount(2, $methodCalls); + $this->assertCount(3, $methodCalls); $this->assertSame(['addHeader', [['Foo: bar', 'Baz: inga']]], $methodCalls[1]); + $this->assertSame(['addParameter', [['--foo bar', '--baz inga']]], $methodCalls[2]); } protected function getContainer($fixture) diff --git a/Tests/DependencyInjection/Fixtures/xml/native_mailer.xml b/Tests/DependencyInjection/Fixtures/xml/native_mailer.xml index 8c3e8242..44347cd1 100644 --- a/Tests/DependencyInjection/Fixtures/xml/native_mailer.xml +++ b/Tests/DependencyInjection/Fixtures/xml/native_mailer.xml @@ -10,6 +10,8 @@
Foo: bar
Baz: inga
+ --foo bar + --baz inga
diff --git a/Tests/DependencyInjection/Fixtures/yml/native_mailer.yml b/Tests/DependencyInjection/Fixtures/yml/native_mailer.yml index 4950a38f..14ba618a 100644 --- a/Tests/DependencyInjection/Fixtures/yml/native_mailer.yml +++ b/Tests/DependencyInjection/Fixtures/yml/native_mailer.yml @@ -8,3 +8,6 @@ monolog: headers: - "Foo: bar" - "Baz: inga" + parameters: + - "--foo bar" + - "--baz inga"