vendor/swiftmailer/lib/classes/Swift/Transport/NullTransport.php
changeset 0 7f95f8617b0b
equal deleted inserted replaced
-1:000000000000 0:7f95f8617b0b
       
     1 <?php
       
     2 
       
     3 /*
       
     4  * This file is part of SwiftMailer.
       
     5  * (c) 2009 Fabien Potencier <fabien.potencier@gmail.com>
       
     6  *
       
     7  * For the full copyright and license information, please view the LICENSE
       
     8  * file that was distributed with this source code.
       
     9  */
       
    10 
       
    11 /**
       
    12  * Pretends messages have been sent, but just ignores them.
       
    13  * @package Swift
       
    14  * @author  Fabien Potencier
       
    15  */
       
    16 class Swift_Transport_NullTransport implements Swift_Transport
       
    17 {
       
    18   /** The event dispatcher from the plugin API */
       
    19   private $_eventDispatcher;
       
    20 
       
    21   /**
       
    22    * Constructor.
       
    23    */
       
    24   public function __construct(Swift_Events_EventDispatcher $eventDispatcher)
       
    25   {
       
    26     $this->_eventDispatcher = $eventDispatcher;
       
    27   }
       
    28   
       
    29   /**
       
    30    * Tests if this Transport mechanism has started.
       
    31    *
       
    32    * @return boolean
       
    33    */
       
    34   public function isStarted()
       
    35   {
       
    36     return true;
       
    37   }
       
    38   
       
    39   /**
       
    40    * Starts this Transport mechanism.
       
    41    */
       
    42   public function start()
       
    43   {
       
    44   }
       
    45   
       
    46   /**
       
    47    * Stops this Transport mechanism.
       
    48    */
       
    49   public function stop()
       
    50   {
       
    51   }
       
    52   
       
    53   /**
       
    54    * Sends the given message.
       
    55    *
       
    56    * @param Swift_Mime_Message $message
       
    57    * @param string[] &$failedRecipients to collect failures by-reference
       
    58    *
       
    59    * @return int The number of sent emails
       
    60    */
       
    61   public function send(Swift_Mime_Message $message, &$failedRecipients = null)
       
    62   {
       
    63     if ($evt = $this->_eventDispatcher->createSendEvent($this, $message))
       
    64     {
       
    65       $this->_eventDispatcher->dispatchEvent($evt, 'beforeSendPerformed');
       
    66       if ($evt->bubbleCancelled())
       
    67       {
       
    68         return 0;
       
    69       }
       
    70     }
       
    71     
       
    72     if ($evt)
       
    73     {
       
    74       $evt->setResult(Swift_Events_SendEvent::RESULT_SUCCESS);
       
    75       $this->_eventDispatcher->dispatchEvent($evt, 'sendPerformed');
       
    76     }
       
    77     
       
    78     return 0;
       
    79   }
       
    80   
       
    81   /**
       
    82    * Register a plugin.
       
    83    *
       
    84    * @param Swift_Events_EventListener $plugin
       
    85    */
       
    86   public function registerPlugin(Swift_Events_EventListener $plugin)
       
    87   {
       
    88     $this->_eventDispatcher->bindEventListener($plugin);
       
    89   }
       
    90 }