diff options
Diffstat (limited to 'vendor/swiftmailer/classes/Swift/Events')
15 files changed, 837 insertions, 0 deletions
diff --git a/vendor/swiftmailer/classes/Swift/Events/CommandEvent.php b/vendor/swiftmailer/classes/Swift/Events/CommandEvent.php new file mode 100644 index 00000000..670f4d3d --- /dev/null +++ b/vendor/swiftmailer/classes/Swift/Events/CommandEvent.php @@ -0,0 +1,65 @@ +<?php + +/* + * This file is part of SwiftMailer. + * (c) 2004-2009 Chris Corbyn + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * Generated when a command is sent over an SMTP connection. + * + * @author Chris Corbyn + */ +class Swift_Events_CommandEvent extends Swift_Events_EventObject +{ + /** + * The command sent to the server. + * + * @var string + */ + private $_command; + + /** + * An array of codes which a successful response will contain. + * + * @var integer[] + */ + private $_successCodes = array(); + + /** + * Create a new CommandEvent for $source with $command. + * + * @param Swift_Transport $source + * @param string $command + * @param array $successCodes + */ + public function __construct(Swift_Transport $source, $command, $successCodes = array()) + { + parent::__construct($source); + $this->_command = $command; + $this->_successCodes = $successCodes; + } + + /** + * Get the command which was sent to the server. + * + * @return string + */ + public function getCommand() + { + return $this->_command; + } + + /** + * Get the numeric response codes which indicate success for this command. + * + * @return integer[] + */ + public function getSuccessCodes() + { + return $this->_successCodes; + } +} diff --git a/vendor/swiftmailer/classes/Swift/Events/CommandListener.php b/vendor/swiftmailer/classes/Swift/Events/CommandListener.php new file mode 100644 index 00000000..3465c8d6 --- /dev/null +++ b/vendor/swiftmailer/classes/Swift/Events/CommandListener.php @@ -0,0 +1,24 @@ +<?php + +/* + * This file is part of SwiftMailer. + * (c) 2004-2009 Chris Corbyn + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * Listens for Transports to send commands to the server. + * + * @author Chris Corbyn + */ +interface Swift_Events_CommandListener extends Swift_Events_EventListener +{ + /** + * Invoked immediately following a command being sent. + * + * @param Swift_Events_CommandEvent $evt + */ + public function commandSent(Swift_Events_CommandEvent $evt); +} diff --git a/vendor/swiftmailer/classes/Swift/Events/Event.php b/vendor/swiftmailer/classes/Swift/Events/Event.php new file mode 100644 index 00000000..ffd9bed1 --- /dev/null +++ b/vendor/swiftmailer/classes/Swift/Events/Event.php @@ -0,0 +1,38 @@ +<?php + +/* + * This file is part of SwiftMailer. + * (c) 2004-2009 Chris Corbyn + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * The minimum interface for an Event. + * + * @author Chris Corbyn + */ +interface Swift_Events_Event +{ + /** + * Get the source object of this event. + * + * @return object + */ + public function getSource(); + + /** + * Prevent this Event from bubbling any further up the stack. + * + * @param bool $cancel, optional + */ + public function cancelBubble($cancel = true); + + /** + * Returns true if this Event will not bubble any further up the stack. + * + * @return bool + */ + public function bubbleCancelled(); +} diff --git a/vendor/swiftmailer/classes/Swift/Events/EventDispatcher.php b/vendor/swiftmailer/classes/Swift/Events/EventDispatcher.php new file mode 100644 index 00000000..c62c5e42 --- /dev/null +++ b/vendor/swiftmailer/classes/Swift/Events/EventDispatcher.php @@ -0,0 +1,83 @@ +<?php + +/* + * This file is part of SwiftMailer. + * (c) 2004-2009 Chris Corbyn + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * Interface for the EventDispatcher which handles the event dispatching layer. + * + * @author Chris Corbyn + */ +interface Swift_Events_EventDispatcher +{ + /** + * Create a new SendEvent for $source and $message. + * + * @param Swift_Transport $source + * @param Swift_Mime_Message + * + * @return Swift_Events_SendEvent + */ + public function createSendEvent(Swift_Transport $source, Swift_Mime_Message $message); + + /** + * Create a new CommandEvent for $source and $command. + * + * @param Swift_Transport $source + * @param string $command That will be executed + * @param array $successCodes That are needed + * + * @return Swift_Events_CommandEvent + */ + public function createCommandEvent(Swift_Transport $source, $command, $successCodes = array()); + + /** + * Create a new ResponseEvent for $source and $response. + * + * @param Swift_Transport $source + * @param string $response + * @param bool $valid If the response is valid + * + * @return Swift_Events_ResponseEvent + */ + public function createResponseEvent(Swift_Transport $source, $response, $valid); + + /** + * Create a new TransportChangeEvent for $source. + * + * @param Swift_Transport $source + * + * @return Swift_Events_TransportChangeEvent + */ + public function createTransportChangeEvent(Swift_Transport $source); + + /** + * Create a new TransportExceptionEvent for $source. + * + * @param Swift_Transport $source + * @param Swift_TransportException $ex + * + * @return Swift_Events_TransportExceptionEvent + */ + public function createTransportExceptionEvent(Swift_Transport $source, Swift_TransportException $ex); + + /** + * Bind an event listener to this dispatcher. + * + * @param Swift_Events_EventListener $listener + */ + public function bindEventListener(Swift_Events_EventListener $listener); + + /** + * Dispatch the given Event to all suitable listeners. + * + * @param Swift_Events_EventObject $evt + * @param string $target method + */ + public function dispatchEvent(Swift_Events_EventObject $evt, $target); +} diff --git a/vendor/swiftmailer/classes/Swift/Events/EventListener.php b/vendor/swiftmailer/classes/Swift/Events/EventListener.php new file mode 100644 index 00000000..751ec678 --- /dev/null +++ b/vendor/swiftmailer/classes/Swift/Events/EventListener.php @@ -0,0 +1,18 @@ +<?php + +/* + * This file is part of SwiftMailer. + * (c) 2004-2009 Chris Corbyn + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * An identity interface which all EventListeners must extend. + * + * @author Chris Corbyn + */ +interface Swift_Events_EventListener +{ +} diff --git a/vendor/swiftmailer/classes/Swift/Events/EventObject.php b/vendor/swiftmailer/classes/Swift/Events/EventObject.php new file mode 100644 index 00000000..50b6be6a --- /dev/null +++ b/vendor/swiftmailer/classes/Swift/Events/EventObject.php @@ -0,0 +1,63 @@ +<?php + +/* + * This file is part of SwiftMailer. + * (c) 2004-2009 Chris Corbyn + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * A base Event which all Event classes inherit from. + * + * @author Chris Corbyn + */ +class Swift_Events_EventObject implements Swift_Events_Event +{ + /** The source of this Event */ + private $_source; + + /** The state of this Event (should it bubble up the stack?) */ + private $_bubbleCancelled = false; + + /** + * Create a new EventObject originating at $source. + * + * @param object $source + */ + public function __construct($source) + { + $this->_source = $source; + } + + /** + * Get the source object of this event. + * + * @return object + */ + public function getSource() + { + return $this->_source; + } + + /** + * Prevent this Event from bubbling any further up the stack. + * + * @param bool $cancel, optional + */ + public function cancelBubble($cancel = true) + { + $this->_bubbleCancelled = $cancel; + } + + /** + * Returns true if this Event will not bubble any further up the stack. + * + * @return bool + */ + public function bubbleCancelled() + { + return $this->_bubbleCancelled; + } +} diff --git a/vendor/swiftmailer/classes/Swift/Events/ResponseEvent.php b/vendor/swiftmailer/classes/Swift/Events/ResponseEvent.php new file mode 100644 index 00000000..6ca9b99a --- /dev/null +++ b/vendor/swiftmailer/classes/Swift/Events/ResponseEvent.php @@ -0,0 +1,66 @@ +<?php + +/* + * This file is part of SwiftMailer. + * (c) 2004-2009 Chris Corbyn + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * Generated when a response is received on a SMTP connection. + * + * @author Chris Corbyn + */ +class Swift_Events_ResponseEvent extends Swift_Events_EventObject +{ + /** + * The overall result. + * + * @var bool + */ + private $_valid; + + /** + * The response received from the server. + * + * @var string + */ + private $_response; + + /** + * Create a new ResponseEvent for $source and $response. + * + * @param Swift_Transport $source + * @param string $response + * @param bool $valid + */ + public function __construct(Swift_Transport $source, $response, $valid = false) + { + parent::__construct($source); + $this->_response = $response; + $this->_valid = $valid; + } + + /** + * Get the response which was received from the server. + * + * @return string + */ + public function getResponse() + { + return $this->_response; + } + + /** + * Get the success status of this Event. + * + * @return bool + */ + public function isValid() + { + return $this->_valid; + } + +} diff --git a/vendor/swiftmailer/classes/Swift/Events/ResponseListener.php b/vendor/swiftmailer/classes/Swift/Events/ResponseListener.php new file mode 100644 index 00000000..9629f1e5 --- /dev/null +++ b/vendor/swiftmailer/classes/Swift/Events/ResponseListener.php @@ -0,0 +1,24 @@ +<?php + +/* + * This file is part of SwiftMailer. + * (c) 2004-2009 Chris Corbyn + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * Listens for responses from a remote SMTP server. + * + * @author Chris Corbyn + */ +interface Swift_Events_ResponseListener extends Swift_Events_EventListener +{ + /** + * Invoked immediately following a response coming back. + * + * @param Swift_Events_ResponseEvent $evt + */ + public function responseReceived(Swift_Events_ResponseEvent $evt); +} diff --git a/vendor/swiftmailer/classes/Swift/Events/SendEvent.php b/vendor/swiftmailer/classes/Swift/Events/SendEvent.php new file mode 100644 index 00000000..0d3b4141 --- /dev/null +++ b/vendor/swiftmailer/classes/Swift/Events/SendEvent.php @@ -0,0 +1,126 @@ +<?php + +/* + * This file is part of SwiftMailer. + * (c) 2004-2009 Chris Corbyn + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * Generated when a message is being sent. + * + * @author Chris Corbyn + */ +class Swift_Events_SendEvent extends Swift_Events_EventObject +{ + /** Sending has yet to occur */ + const RESULT_PENDING = 0x0001; + + /** Sending was successful */ + const RESULT_SUCCESS = 0x0010; + + /** Sending worked, but there were some failures */ + const RESULT_TENTATIVE = 0x0100; + + /** Sending failed */ + const RESULT_FAILED = 0x1000; + + /** + * The Message being sent. + * + * @var Swift_Mime_Message + */ + private $_message; + + /** + * Any recipients which failed after sending. + * + * @var string[] + */ + private $_failedRecipients = array(); + + /** + * The overall result as a bitmask from the class constants. + * + * @var int + */ + private $_result; + + /** + * Create a new SendEvent for $source and $message. + * + * @param Swift_Transport $source + * @param Swift_Mime_Message $message + */ + public function __construct(Swift_Transport $source, Swift_Mime_Message $message) + { + parent::__construct($source); + $this->_message = $message; + $this->_result = self::RESULT_PENDING; + } + + /** + * Get the Transport used to send the Message. + * + * @return Swift_Transport + */ + public function getTransport() + { + return $this->getSource(); + } + + /** + * Get the Message being sent. + * + * @return Swift_Mime_Message + */ + public function getMessage() + { + return $this->_message; + } + + /** + * Set the array of addresses that failed in sending. + * + * @param array $recipients + */ + public function setFailedRecipients($recipients) + { + $this->_failedRecipients = $recipients; + } + + /** + * Get an recipient addresses which were not accepted for delivery. + * + * @return string[] + */ + public function getFailedRecipients() + { + return $this->_failedRecipients; + } + + /** + * Set the result of sending. + * + * @param int $result + */ + public function setResult($result) + { + $this->_result = $result; + } + + /** + * Get the result of this Event. + * + * The return value is a bitmask from + * {@see RESULT_PENDING, RESULT_SUCCESS, RESULT_TENTATIVE, RESULT_FAILED} + * + * @return int + */ + public function getResult() + { + return $this->_result; + } +} diff --git a/vendor/swiftmailer/classes/Swift/Events/SendListener.php b/vendor/swiftmailer/classes/Swift/Events/SendListener.php new file mode 100644 index 00000000..7d35f18e --- /dev/null +++ b/vendor/swiftmailer/classes/Swift/Events/SendListener.php @@ -0,0 +1,31 @@ +<?php + +/* + * This file is part of SwiftMailer. + * (c) 2004-2009 Chris Corbyn + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * Listens for Messages being sent from within the Transport system. + * + * @author Chris Corbyn + */ +interface Swift_Events_SendListener extends Swift_Events_EventListener +{ + /** + * Invoked immediately before the Message is sent. + * + * @param Swift_Events_SendEvent $evt + */ + public function beforeSendPerformed(Swift_Events_SendEvent $evt); + + /** + * Invoked immediately after the Message is sent. + * + * @param Swift_Events_SendEvent $evt + */ + public function sendPerformed(Swift_Events_SendEvent $evt); +} diff --git a/vendor/swiftmailer/classes/Swift/Events/SimpleEventDispatcher.php b/vendor/swiftmailer/classes/Swift/Events/SimpleEventDispatcher.php new file mode 100644 index 00000000..b7f82aed --- /dev/null +++ b/vendor/swiftmailer/classes/Swift/Events/SimpleEventDispatcher.php @@ -0,0 +1,157 @@ +<?php + +/* + * This file is part of SwiftMailer. + * (c) 2004-2009 Chris Corbyn + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * The EventDispatcher which handles the event dispatching layer. + * + * @author Chris Corbyn + */ +class Swift_Events_SimpleEventDispatcher implements Swift_Events_EventDispatcher +{ + /** A map of event types to their associated listener types */ + private $_eventMap = array(); + + /** Event listeners bound to this dispatcher */ + private $_listeners = array(); + + /** Listeners queued to have an Event bubbled up the stack to them */ + private $_bubbleQueue = array(); + + /** + * Create a new EventDispatcher. + */ + public function __construct() + { + $this->_eventMap = array( + 'Swift_Events_CommandEvent' => 'Swift_Events_CommandListener', + 'Swift_Events_ResponseEvent' => 'Swift_Events_ResponseListener', + 'Swift_Events_SendEvent' => 'Swift_Events_SendListener', + 'Swift_Events_TransportChangeEvent' => 'Swift_Events_TransportChangeListener', + 'Swift_Events_TransportExceptionEvent' => 'Swift_Events_TransportExceptionListener' + ); + } + + /** + * Create a new SendEvent for $source and $message. + * + * @param Swift_Transport $source + * @param Swift_Mime_Message + * + * @return Swift_Events_SendEvent + */ + public function createSendEvent(Swift_Transport $source, Swift_Mime_Message $message) + { + return new Swift_Events_SendEvent($source, $message); + } + + /** + * Create a new CommandEvent for $source and $command. + * + * @param Swift_Transport $source + * @param string $command That will be executed + * @param array $successCodes That are needed + * + * @return Swift_Events_CommandEvent + */ + public function createCommandEvent(Swift_Transport $source, $command, $successCodes = array()) + { + return new Swift_Events_CommandEvent($source, $command, $successCodes); + } + + /** + * Create a new ResponseEvent for $source and $response. + * + * @param Swift_Transport $source + * @param string $response + * @param bool $valid If the response is valid + * + * @return Swift_Events_ResponseEvent + */ + public function createResponseEvent(Swift_Transport $source, $response, $valid) + { + return new Swift_Events_ResponseEvent($source, $response, $valid); + } + + /** + * Create a new TransportChangeEvent for $source. + * + * @param Swift_Transport $source + * + * @return Swift_Events_TransportChangeEvent + */ + public function createTransportChangeEvent(Swift_Transport $source) + { + return new Swift_Events_TransportChangeEvent($source); + } + + /** + * Create a new TransportExceptionEvent for $source. + * + * @param Swift_Transport $source + * @param Swift_TransportException $ex + * + * @return Swift_Events_TransportExceptionEvent + */ + public function createTransportExceptionEvent(Swift_Transport $source, Swift_TransportException $ex) + { + return new Swift_Events_TransportExceptionEvent($source, $ex); + } + + /** + * Bind an event listener to this dispatcher. + * + * @param Swift_Events_EventListener $listener + */ + public function bindEventListener(Swift_Events_EventListener $listener) + { + foreach ($this->_listeners as $l) { + // Already loaded + if ($l === $listener) { + return; + } + } + $this->_listeners[] = $listener; + } + + /** + * Dispatch the given Event to all suitable listeners. + * + * @param Swift_Events_EventObject $evt + * @param string $target method + */ + public function dispatchEvent(Swift_Events_EventObject $evt, $target) + { + $this->_prepareBubbleQueue($evt); + $this->_bubble($evt, $target); + } + + /** Queue listeners on a stack ready for $evt to be bubbled up it */ + private function _prepareBubbleQueue(Swift_Events_EventObject $evt) + { + $this->_bubbleQueue = array(); + $evtClass = get_class($evt); + foreach ($this->_listeners as $listener) { + if (array_key_exists($evtClass, $this->_eventMap) + && ($listener instanceof $this->_eventMap[$evtClass])) + { + $this->_bubbleQueue[] = $listener; + } + } + } + + /** Bubble $evt up the stack calling $target() on each listener */ + private function _bubble(Swift_Events_EventObject $evt, $target) + { + if (!$evt->bubbleCancelled() && $listener = array_shift($this->_bubbleQueue)) { + $listener->$target($evt); + $this->_bubble($evt, $target); + } + } +} diff --git a/vendor/swiftmailer/classes/Swift/Events/TransportChangeEvent.php b/vendor/swiftmailer/classes/Swift/Events/TransportChangeEvent.php new file mode 100644 index 00000000..23c82970 --- /dev/null +++ b/vendor/swiftmailer/classes/Swift/Events/TransportChangeEvent.php @@ -0,0 +1,27 @@ +<?php + +/* + * This file is part of SwiftMailer. + * (c) 2004-2009 Chris Corbyn + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * Generated when the state of a Transport is changed (i.e. stopped/started). + * + * @author Chris Corbyn + */ +class Swift_Events_TransportChangeEvent extends Swift_Events_EventObject +{ + /** + * Get the Transport. + * + * @return Swift_Transport + */ + public function getTransport() + { + return $this->getSource(); + } +} diff --git a/vendor/swiftmailer/classes/Swift/Events/TransportChangeListener.php b/vendor/swiftmailer/classes/Swift/Events/TransportChangeListener.php new file mode 100644 index 00000000..0edfe377 --- /dev/null +++ b/vendor/swiftmailer/classes/Swift/Events/TransportChangeListener.php @@ -0,0 +1,45 @@ +<?php + +/* + * This file is part of SwiftMailer. + * (c) 2004-2009 Chris Corbyn + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * Listens for changes within the Transport system. + * + * @author Chris Corbyn + */ +interface Swift_Events_TransportChangeListener extends Swift_Events_EventListener +{ + /** + * Invoked just before a Transport is started. + * + * @param Swift_Events_TransportChangeEvent $evt + */ + public function beforeTransportStarted(Swift_Events_TransportChangeEvent $evt); + + /** + * Invoked immediately after the Transport is started. + * + * @param Swift_Events_TransportChangeEvent $evt + */ + public function transportStarted(Swift_Events_TransportChangeEvent $evt); + + /** + * Invoked just before a Transport is stopped. + * + * @param Swift_Events_TransportChangeEvent $evt + */ + public function beforeTransportStopped(Swift_Events_TransportChangeEvent $evt); + + /** + * Invoked immediately after the Transport is stopped. + * + * @param Swift_Events_TransportChangeEvent $evt + */ + public function transportStopped(Swift_Events_TransportChangeEvent $evt); +} diff --git a/vendor/swiftmailer/classes/Swift/Events/TransportExceptionEvent.php b/vendor/swiftmailer/classes/Swift/Events/TransportExceptionEvent.php new file mode 100644 index 00000000..b2c72ca1 --- /dev/null +++ b/vendor/swiftmailer/classes/Swift/Events/TransportExceptionEvent.php @@ -0,0 +1,46 @@ +<?php + +/* + * This file is part of SwiftMailer. + * (c) 2004-2009 Chris Corbyn + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * Generated when a TransportException is thrown from the Transport system. + * + * @author Chris Corbyn + */ +class Swift_Events_TransportExceptionEvent extends Swift_Events_EventObject +{ + /** + * The Exception thrown. + * + * @var Swift_TransportException + */ + private $_exception; + + /** + * Create a new TransportExceptionEvent for $transport. + * + * @param Swift_Transport $transport + * @param Swift_TransportException $ex + */ + public function __construct(Swift_Transport $transport, Swift_TransportException $ex) + { + parent::__construct($transport); + $this->_exception = $ex; + } + + /** + * Get the TransportException thrown. + * + * @return Swift_TransportException + */ + public function getException() + { + return $this->_exception; + } +} diff --git a/vendor/swiftmailer/classes/Swift/Events/TransportExceptionListener.php b/vendor/swiftmailer/classes/Swift/Events/TransportExceptionListener.php new file mode 100644 index 00000000..f153742c --- /dev/null +++ b/vendor/swiftmailer/classes/Swift/Events/TransportExceptionListener.php @@ -0,0 +1,24 @@ +<?php + +/* + * This file is part of SwiftMailer. + * (c) 2004-2009 Chris Corbyn + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * Listens for Exceptions thrown from within the Transport system. + * + * @author Chris Corbyn + */ +interface Swift_Events_TransportExceptionListener extends Swift_Events_EventListener +{ + /** + * Invoked as a TransportException is thrown in the Transport system. + * + * @param Swift_Events_TransportExceptionEvent $evt + */ + public function exceptionThrown(Swift_Events_TransportExceptionEvent $evt); +} |