TYPO3 API  SVNRelease
SendEvent.php
Go to the documentation of this file.
00001 <?php
00002 
00003 /*
00004  * This file is part of SwiftMailer.
00005  * (c) 2004-2009 Chris Corbyn
00006  *
00007  * For the full copyright and license information, please view the LICENSE
00008  * file that was distributed with this source code.
00009  */
00010 
00011 //@require 'Swift/Events/EventObject.php';
00012 
00013 /**
00014  * Generated when a message is being sent.
00015  * @package Swift
00016  * @subpackage Events
00017  * @author Chris Corbyn
00018  */
00019 class Swift_Events_SendEvent extends Swift_Events_EventObject
00020 {
00021 
00022   /** Sending has yet to occur */
00023   const RESULT_PENDING = 0x0001;
00024 
00025   /** Sending was successful */
00026   const RESULT_SUCCESS = 0x0010;
00027 
00028   /** Sending worked, but there were some failures */
00029   const RESULT_TENTATIVE = 0x0100;
00030 
00031   /** Sending failed */
00032   const RESULT_FAILED = 0x1000;
00033 
00034   /**
00035    * The Message being sent.
00036    * @var Swift_Mime_Message
00037    */
00038   private $_message;
00039 
00040   /**
00041    * The Transport used in sending.
00042    * @var Swift_Transport
00043    */
00044   private $_transport;
00045 
00046   /**
00047    * Any recipients which failed after sending.
00048    * @var string[]
00049    */
00050   private $failedRecipients = array();
00051 
00052   /**
00053    * The overall result as a bitmask from the class constants.
00054    * @var int
00055    */
00056   private $result;
00057 
00058   /**
00059    * Create a new SendEvent for $source and $message.
00060    * @param Swift_Transport $source
00061    * @param Swift_Mime_Message $message
00062    */
00063   public function __construct(Swift_Transport $source,
00064     Swift_Mime_Message $message)
00065   {
00066     parent::__construct($source);
00067     $this->_message = $message;
00068     $this->_result = self::RESULT_PENDING;
00069   }
00070 
00071   /**
00072    * Get the Transport used to send the Message.
00073    * @return Swift_Transport
00074    */
00075   public function getTransport()
00076   {
00077     return $this->getSource();
00078   }
00079 
00080   /**
00081    * Get the Message being sent.
00082    * @return Swift_Mime_Message
00083    */
00084   public function getMessage()
00085   {
00086     return $this->_message;
00087   }
00088 
00089   /**
00090    * Set the array of addresses that failed in sending.
00091    * @param array $recipients
00092    */
00093   public function setFailedRecipients($recipients)
00094   {
00095     $this->_failedRecipients = $recipients;
00096   }
00097 
00098   /**
00099    * Get an recipient addresses which were not accepted for delivery.
00100    * @return string[]
00101    */
00102   public function getFailedRecipients()
00103   {
00104     return $this->_failedRecipients;
00105   }
00106 
00107   /**
00108    * Set the result of sending.
00109    * @return int
00110    */
00111   public function setResult($result)
00112   {
00113     $this->_result = $result;
00114   }
00115 
00116   /**
00117    * Get the result of this Event.
00118    * The return value is a bitmask from
00119    * {@link RESULT_PENDING, RESULT_SUCCESS, RESULT_TENTATIVE, RESULT_FAILED}
00120    * @return int
00121    */
00122   public function getResult()
00123   {
00124     return $this->_result;
00125   }
00126 
00127 }