vendor/swiftmailer/lib/classes/Swift/Events/SendEvent.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) 2004-2009 Chris Corbyn
       
     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 /**
       
    13  * Generated when a message is being sent.
       
    14  * @package Swift
       
    15  * @subpackage Events
       
    16  * @author Chris Corbyn
       
    17  */
       
    18 class Swift_Events_SendEvent extends Swift_Events_EventObject
       
    19 {
       
    20   
       
    21   /** Sending has yet to occur */
       
    22   const RESULT_PENDING = 0x0001;
       
    23   
       
    24   /** Sending was successful */
       
    25   const RESULT_SUCCESS = 0x0010;
       
    26   
       
    27   /** Sending worked, but there were some failures */
       
    28   const RESULT_TENTATIVE = 0x0100;
       
    29   
       
    30   /** Sending failed */
       
    31   const RESULT_FAILED = 0x1000;
       
    32   
       
    33   /**
       
    34    * The Message being sent.
       
    35    * @var Swift_Mime_Message
       
    36    */
       
    37   private $_message;
       
    38   
       
    39   /**
       
    40    * The Transport used in sending.
       
    41    * @var Swift_Transport
       
    42    */
       
    43   private $_transport;
       
    44   
       
    45   /**
       
    46    * Any recipients which failed after sending.
       
    47    * @var string[]
       
    48    */
       
    49   private $_failedRecipients = array();
       
    50   
       
    51   /**
       
    52    * The overall result as a bitmask from the class constants.
       
    53    * @var int
       
    54    */
       
    55   private $result;
       
    56   
       
    57   /**
       
    58    * Create a new SendEvent for $source and $message.
       
    59    * @param Swift_Transport $source
       
    60    * @param Swift_Mime_Message $message
       
    61    */
       
    62   public function __construct(Swift_Transport $source,
       
    63     Swift_Mime_Message $message)
       
    64   {
       
    65     parent::__construct($source);
       
    66     $this->_message = $message;
       
    67     $this->_result = self::RESULT_PENDING;
       
    68   }
       
    69   
       
    70   /**
       
    71    * Get the Transport used to send the Message.
       
    72    * @return Swift_Transport
       
    73    */
       
    74   public function getTransport()
       
    75   {
       
    76     return $this->getSource();
       
    77   }
       
    78   
       
    79   /**
       
    80    * Get the Message being sent.
       
    81    * @return Swift_Mime_Message
       
    82    */
       
    83   public function getMessage()
       
    84   {
       
    85     return $this->_message;
       
    86   }
       
    87   
       
    88   /**
       
    89    * Set the array of addresses that failed in sending.
       
    90    * @param array $recipients
       
    91    */
       
    92   public function setFailedRecipients($recipients)
       
    93   {
       
    94     $this->_failedRecipients = $recipients;
       
    95   }
       
    96   
       
    97   /**
       
    98    * Get an recipient addresses which were not accepted for delivery.
       
    99    * @return string[]
       
   100    */
       
   101   public function getFailedRecipients()
       
   102   {
       
   103     return $this->_failedRecipients;
       
   104   }
       
   105   
       
   106   /**
       
   107    * Set the result of sending.
       
   108    * @return int
       
   109    */
       
   110   public function setResult($result)
       
   111   {
       
   112     $this->_result = $result;
       
   113   }
       
   114   
       
   115   /**
       
   116    * Get the result of this Event.
       
   117    * The return value is a bitmask from
       
   118    * {@link RESULT_PENDING, RESULT_SUCCESS, RESULT_TENTATIVE, RESULT_FAILED}
       
   119    * @return int
       
   120    */
       
   121   public function getResult()
       
   122   {
       
   123     return $this->_result;
       
   124   }
       
   125   
       
   126 }