From 4dcc4ad3871d5586bc53f5dda6e1374eda2c98ce Mon Sep 17 00:00:00 2001 From: ornicar Date: Fri, 29 Jul 2011 16:25:23 -0700 Subject: [PATCH] [SwiftmailerBundle] Allow non-file spools Actually if I have the following configuration: swiftmailer: spool: type: not_file path: some_path The DIC compiler will complain: 'The service "swiftmailer.spool.file" has a dependency on a non-existent parameter "swiftmailer.spool.file.path" Because the file spool service is declared no matter the spool type configured. And it requires the file.path, which is not available. This patch aims to load the file spooler only if required by the configuration. --- DependencyInjection/SwiftmailerExtension.php | 3 +++ Resources/config/spool.xml | 8 -------- Resources/config/spool_file.xml | 16 ++++++++++++++++ 3 files changed, 19 insertions(+), 8 deletions(-) create mode 100644 Resources/config/spool_file.xml diff --git a/DependencyInjection/SwiftmailerExtension.php b/DependencyInjection/SwiftmailerExtension.php index 0c9f4862..1af456b8 100644 --- a/DependencyInjection/SwiftmailerExtension.php +++ b/DependencyInjection/SwiftmailerExtension.php @@ -86,6 +86,9 @@ public function load(array $configs, ContainerBuilder $container) $type = $config['spool']['type']; $loader->load('spool.xml'); + if ($type === 'file') { + $loader->load('spool_file.xml'); + } $container->setAlias('swiftmailer.transport.real', $transport); $container->setAlias('swiftmailer.transport', 'swiftmailer.transport.spool'); $container->setAlias('swiftmailer.spool', 'swiftmailer.spool.'.$type); diff --git a/Resources/config/spool.xml b/Resources/config/spool.xml index 2c37d688..d9009d7b 100644 --- a/Resources/config/spool.xml +++ b/Resources/config/spool.xml @@ -5,8 +5,6 @@ xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> - Swift_FileSpool - Swift_Plugins_RedirectingPlugin Swift_Plugins_BlackholePlugin @@ -16,11 +14,5 @@ - - - %swiftmailer.spool.file.path% - - - diff --git a/Resources/config/spool_file.xml b/Resources/config/spool_file.xml new file mode 100644 index 00000000..b452553e --- /dev/null +++ b/Resources/config/spool_file.xml @@ -0,0 +1,16 @@ + + + + + + Swift_FileSpool + + + + + %swiftmailer.spool.file.path% + + +