diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 5343ca55..31fc2226 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -111,7 +111,17 @@ private function getMailersNode() ->end() ->end() ->scalarNode('sender_address')->end() - ->scalarNode('delivery_address')->end() + ->variableNode('delivery_address') + ->info('Forces the to: header can be a single email "example@example.com" or an array of delivery addresses') + ->validate() + ->ifTrue( + function ($value) { + return !is_array($value) && !is_string($value); + } + ) + ->thenInvalid('Delivery address must be either an array of email addresses or a singe email address.') + ->end() + ->end() ->arrayNode('antiflood') ->children() ->scalarNode('threshold')->defaultValue(99)->end() diff --git a/Resources/config/schema/swiftmailer-1.0.xsd b/Resources/config/schema/swiftmailer-1.0.xsd index 86eae694..34add9ac 100644 --- a/Resources/config/schema/swiftmailer-1.0.xsd +++ b/Resources/config/schema/swiftmailer-1.0.xsd @@ -66,6 +66,10 @@ + + + + diff --git a/Tests/DependencyInjection/Fixtures/config/php/redirect_multi.php b/Tests/DependencyInjection/Fixtures/config/php/redirect_multi.php new file mode 100644 index 00000000..cd949956 --- /dev/null +++ b/Tests/DependencyInjection/Fixtures/config/php/redirect_multi.php @@ -0,0 +1,4 @@ +loadFromExtension('swiftmailer', array( + 'delivery_address' => array('first@host.com', 'second@host.com') +)); diff --git a/Tests/DependencyInjection/Fixtures/config/xml/redirect_multi.xml b/Tests/DependencyInjection/Fixtures/config/xml/redirect_multi.xml new file mode 100644 index 00000000..1daab48b --- /dev/null +++ b/Tests/DependencyInjection/Fixtures/config/xml/redirect_multi.xml @@ -0,0 +1,12 @@ + + + + + first@host.com + second@host.com + + diff --git a/Tests/DependencyInjection/Fixtures/config/yml/redirect_multi.yml b/Tests/DependencyInjection/Fixtures/config/yml/redirect_multi.yml new file mode 100644 index 00000000..f63063ce --- /dev/null +++ b/Tests/DependencyInjection/Fixtures/config/yml/redirect_multi.yml @@ -0,0 +1,2 @@ +swiftmailer: + delivery_address: [first@host.com, second@host.com] diff --git a/Tests/DependencyInjection/SwiftmailerExtensionTest.php b/Tests/DependencyInjection/SwiftmailerExtensionTest.php index 4a777a33..1c5f2804 100644 --- a/Tests/DependencyInjection/SwiftmailerExtensionTest.php +++ b/Tests/DependencyInjection/SwiftmailerExtensionTest.php @@ -251,6 +251,17 @@ public function testSingleRedirectionConfig($type) $this->assertEquals(array('/foo@.*/'), $container->getParameter('swiftmailer.mailer.default.delivery_whitelist')); } + /** + * @dataProvider getConfigTypes + */ + public function testMultiRedirectionConfig($type) + { + $container = $this->loadContainerFromFile('redirect_multi', $type); + + $this->assertSame(array('swiftmailer.default.plugin' => array(array())), $container->getDefinition('swiftmailer.mailer.default.plugin.redirecting')->getTags()); + $this->assertSame(array('first@host.com', 'second@host.com'), $container->getParameter('swiftmailer.mailer.default.single_address')); + } + /** * @dataProvider getConfigTypes */