[SwiftmailerBundle] made data collector configurable via the logging option

This commit is contained in:
Fabien Potencier 2011-03-17 08:06:38 +01:00
parent 95532cc1de
commit 8c6f135534
4 changed files with 9 additions and 4 deletions

View File

@ -65,7 +65,9 @@ class Configuration
->scalarNode('path')->defaultValue('%kernel.cache_dir%/swiftmailer/spool')->end() ->scalarNode('path')->defaultValue('%kernel.cache_dir%/swiftmailer/spool')->end()
->end() ->end()
->scalarNode('delivery_address')->end() ->scalarNode('delivery_address')->end()
->booleanNode('disable_delivery')->end(); ->booleanNode('disable_delivery')->end()
->booleanNode('logging')->defaultValue(false)->end()
;
return $treeBuilder->buildTree(); return $treeBuilder->buildTree();
} }

View File

@ -93,7 +93,10 @@ class SwiftmailerExtension extends Extension
} }
} }
if ($config['logging']) {
$container->findDefinition('swiftmailer.transport')->addMethodCall('registerPlugin', array(new Reference('swiftmailer.plugin.messagelogger'))); $container->findDefinition('swiftmailer.transport')->addMethodCall('registerPlugin', array(new Reference('swiftmailer.plugin.messagelogger')));
$container->findDefinition('data_collector.swiftmailer')->addTag('data_collector', array('template' => 'SwiftmailerBundle:Collector:swiftmailer', 'id' => 'swiftmailer'));
}
if (isset($config['delivery_address']) && $config['delivery_address']) { if (isset($config['delivery_address']) && $config['delivery_address']) {
$container->setParameter('swiftmailer.single_address', $config['delivery_address']); $container->setParameter('swiftmailer.single_address', $config['delivery_address']);

View File

@ -22,6 +22,7 @@
<xsd:attribute name="type" type="xsd:string" /> <xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="delivery-address" type="xsd:string" /> <xsd:attribute name="delivery-address" type="xsd:string" />
<xsd:attribute name="disable-delivery" type="xsd:boolean" /> <xsd:attribute name="disable-delivery" type="xsd:boolean" />
<xsd:attribute name="logging" type="xsd:string" />
</xsd:complexType> </xsd:complexType>
<xsd:complexType name="spool"> <xsd:complexType name="spool">

View File

@ -68,8 +68,7 @@
<service id="swiftmailer.plugin.messagelogger" class="%swiftmailer.plugin.messagelogger.class%" public="false" /> <service id="swiftmailer.plugin.messagelogger" class="%swiftmailer.plugin.messagelogger.class%" public="false" />
<service id="swiftmailer.data_collector" class="%swiftmailer.data_collector.class%" public="false"> <service id="data_collector.swiftmailer" class="%swiftmailer.data_collector.class%" public="false">
<tag name="data_collector" template="SwiftmailerBundle:Collector:message" id="swiftmailer" />
<argument type="service" id="swiftmailer.plugin.messagelogger" /> <argument type="service" id="swiftmailer.plugin.messagelogger" />
<argument type="service" id="swiftmailer.mailer" /> <argument type="service" id="swiftmailer.mailer" />
</service> </service>