Bläddra i källkod

[SwiftmailerBundle] added the mailer as a dependency to the data collector to ensure that Swiftmailer is always initialized

Fabien Potencier 14 år sedan
förälder
incheckning
3346e291f2

+ 7 - 4
src/Symfony/Bundle/SwiftmailerBundle/DataCollector/MessageDataCollector.php

@@ -18,15 +18,18 @@ use Symfony\Component\HttpFoundation\Response;
 /**
  * MessageDataCollector.
  *
+ * @author Fabien Potencier <fabien@symfony.com>
  * @author Clément JOBEILI <clement.jobeili@gmail.com>
  */
 class MessageDataCollector extends DataCollector
 {
     protected $logger;
-    
-    public function __construct(\Swift_Events_SendListener $logger)
+
+    public function __construct(\Swift_Events_SendListener $logger, \Swift_Mailer $mailer)
     {
         $this->logger = $logger;
+        // we do nothing with the mailer
+        // it's in the constructor just to force SwiftMailer to be initialized
     }
 
     /**
@@ -37,7 +40,7 @@ class MessageDataCollector extends DataCollector
         $this->data['messages'] = $this->logger->getMessages();
         $this->data['messageCount'] = $this->logger->countMessages();
     }
-    
+
     public function getMessageCount()
     {
         return $this->data['messageCount'];
@@ -47,7 +50,7 @@ class MessageDataCollector extends DataCollector
     {
         return $this->data['messages'];
     }
-    
+
     /**
      * {@inheritdoc}
      */

+ 1 - 0
src/Symfony/Bundle/SwiftmailerBundle/Resources/config/swiftmailer.xml

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