vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/SpoolTransport.php line 94

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of SwiftMailer.
  4.  * (c) 2009 Fabien Potencier <fabien.potencier@gmail.com>
  5.  *
  6.  * For the full copyright and license information, please view the LICENSE
  7.  * file that was distributed with this source code.
  8.  */
  9. /**
  10.  * Stores Messages in a queue.
  11.  *
  12.  * @author Fabien Potencier
  13.  */
  14. class Swift_Transport_SpoolTransport implements Swift_Transport
  15. {
  16.     /** The spool instance */
  17.     private $spool;
  18.     /** The event dispatcher from the plugin API */
  19.     private $eventDispatcher;
  20.     /**
  21.      * Constructor.
  22.      */
  23.     public function __construct(Swift_Events_EventDispatcher $eventDispatcherSwift_Spool $spool null)
  24.     {
  25.         $this->eventDispatcher $eventDispatcher;
  26.         $this->spool $spool;
  27.     }
  28.     /**
  29.      * Sets the spool object.
  30.      *
  31.      * @return $this
  32.      */
  33.     public function setSpool(Swift_Spool $spool)
  34.     {
  35.         $this->spool $spool;
  36.         return $this;
  37.     }
  38.     /**
  39.      * Get the spool object.
  40.      *
  41.      * @return Swift_Spool
  42.      */
  43.     public function getSpool()
  44.     {
  45.         return $this->spool;
  46.     }
  47.     /**
  48.      * Tests if this Transport mechanism has started.
  49.      *
  50.      * @return bool
  51.      */
  52.     public function isStarted()
  53.     {
  54.         return true;
  55.     }
  56.     /**
  57.      * Starts this Transport mechanism.
  58.      */
  59.     public function start()
  60.     {
  61.     }
  62.     /**
  63.      * Stops this Transport mechanism.
  64.      */
  65.     public function stop()
  66.     {
  67.     }
  68.     /**
  69.      * {@inheritdoc}
  70.      */
  71.     public function ping()
  72.     {
  73.         return true;
  74.     }
  75.     /**
  76.      * Sends the given message.
  77.      *
  78.      * @param string[] $failedRecipients An array of failures by-reference
  79.      *
  80.      * @return int The number of sent e-mail's
  81.      */
  82.     public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients null)
  83.     {
  84.         if ($evt $this->eventDispatcher->createSendEvent($this$message)) {
  85.             $this->eventDispatcher->dispatchEvent($evt'beforeSendPerformed');
  86.             if ($evt->bubbleCancelled()) {
  87.                 return 0;
  88.             }
  89.         }
  90.         $success $this->spool->queueMessage($message);
  91.         if ($evt) {
  92.             $evt->setResult($success Swift_Events_SendEvent::RESULT_SPOOLED Swift_Events_SendEvent::RESULT_FAILED);
  93.             $this->eventDispatcher->dispatchEvent($evt'sendPerformed');
  94.         }
  95.         return 1;
  96.     }
  97.     /**
  98.      * Register a plugin.
  99.      */
  100.     public function registerPlugin(Swift_Events_EventListener $plugin)
  101.     {
  102.         $this->eventDispatcher->bindEventListener($plugin);
  103.     }
  104. }