Skip to content
This repository has been archived by the owner on Feb 6, 2022. It is now read-only.

Commit

Permalink
[SwiftmailerBundle] Allow non-file spools
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ornicar committed Jul 29, 2011
1 parent 6917cd8 commit 4dcc4ad
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
3 changes: 3 additions & 0 deletions DependencyInjection/SwiftmailerExtension.php
Expand Up @@ -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);
Expand Down
8 changes: 0 additions & 8 deletions Resources/config/spool.xml
Expand Up @@ -5,8 +5,6 @@
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">

<parameters>
<parameter key="swiftmailer.spool.file.class">Swift_FileSpool</parameter>

<parameter key="swiftmailer.plugin.redirecting.class">Swift_Plugins_RedirectingPlugin</parameter>
<parameter key="swiftmailer.plugin.blackhole.class">Swift_Plugins_BlackholePlugin</parameter>
</parameters>
Expand All @@ -16,11 +14,5 @@
<argument type="service" id="swiftmailer.transport.eventdispatcher" />
<argument type="service" id="swiftmailer.spool" />
</service>

<service id="swiftmailer.spool.file" class="%swiftmailer.spool.file.class%" public="false">
<argument>%swiftmailer.spool.file.path%</argument>
</service>

<service id="swiftmailer.spool" alias="swiftmailer.spool.file" public="false" />
</services>
</container>
16 changes: 16 additions & 0 deletions Resources/config/spool_file.xml
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8" ?>

<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">

<parameters>
<parameter key="swiftmailer.spool.file.class">Swift_FileSpool</parameter>
</parameters>

<services>
<service id="swiftmailer.spool.file" class="%swiftmailer.spool.file.class%" public="false">
<argument>%swiftmailer.spool.file.path%</argument>
</service>
</services>
</container>

0 comments on commit 4dcc4ad

Please sign in to comment.