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

Commit

Permalink
merged arjenjb/swift-antiflood-plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Jun 6, 2011
2 parents 4b924bc + 4b2da55 commit cc1656b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
6 changes: 6 additions & 0 deletions DependencyInjection/Configuration.php
Expand Up @@ -81,6 +81,12 @@ public function getConfigTreeBuilder()
->end()
->end()
->scalarNode('sender_address')->end()
->arrayNode('antiflood')
->children()
->scalarNode('treshold')->defaultValue(99)->end()
->scalarNode('sleep')->defaultValue(0)->end()
->end()
->end()
->scalarNode('delivery_address')->end()
->booleanNode('disable_delivery')->end()
->booleanNode('logging')->defaultValue($this->debug)->end()
Expand Down
15 changes: 14 additions & 1 deletion DependencyInjection/SwiftmailerExtension.php
Expand Up @@ -90,7 +90,20 @@ public function load(array $configs, ContainerBuilder $container)
}
}
$container->setParameter('swiftmailer.spool.enabled', isset($config['spool']));


// antiflood?
if (isset($config['antiflood'])) {
foreach (array('treshold', 'sleep') as $key) {
$container->setParameter('swiftmailer.antiflood.'.$key, $config['antiflood'][$key]);
}

$container->findDefinition('swiftmailer.transport')->addMethodCall('registerPlugin', array(new Reference('swiftmailer.plugin.antiflood')));
} else {
foreach (array('treshold', 'sleep') as $key) {
$container->setParameter('swiftmailer.antiflood.'.$key, null);
}
}

if ($config['logging']) {
$container->findDefinition('swiftmailer.transport')->addMethodCall('registerPlugin', array(new Reference('swiftmailer.plugin.messagelogger')));
$container->findDefinition('swiftmailer.data_collector')->addTag('data_collector', array('template' => 'SwiftmailerBundle:Collector:swiftmailer', 'id' => 'swiftmailer'));
Expand Down
7 changes: 7 additions & 0 deletions Resources/config/swiftmailer.xml
Expand Up @@ -16,6 +16,8 @@
<parameter key="swiftmailer.plugin.blackhole.class">Swift_Plugins_BlackholePlugin</parameter>
<parameter key="swiftmailer.plugin.impersonate.class">Swift_Plugins_ImpersonatePlugin</parameter>
<parameter key="swiftmailer.plugin.messagelogger.class">Symfony\Bundle\SwiftmailerBundle\Logger\MessageLogger</parameter>
<parameter key="swiftmailer.plugin.antiflood.class">Swift_Plugins_AntiFloodPlugin</parameter>

<parameter key="swiftmailer.data_collector.class">Symfony\Bundle\SwiftmailerBundle\DataCollector\MessageDataCollector</parameter>
</parameters>

Expand Down Expand Up @@ -63,6 +65,11 @@
</service>

<service id="swiftmailer.plugin.blackhole" class="%swiftmailer.plugin.blackhole.class%" public="false" />

<service id="swiftmailer.plugin.antiflood" class="%swiftmailer.plugin.antiflood.class%" public="false">
<argument>%swiftmailer.antiflood.treshold%</argument>
<argument>%swiftmailer.antiflood.sleep%</argument>
</service>

<service id="swiftmailer.plugin.impersonate" class="%swiftmailer.plugin.impersonate.class%" public="false">
<argument>%swiftmailer.sender_address%</argument>
Expand Down

0 comments on commit cc1656b

Please sign in to comment.