Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 141 lines (125 sloc) 3.541 kb
0c9a6c1 Benjamin Steininger Init
authored
1 <?php
d7a779f Benjamin Steininger Some code-formatting and minor additions
authored
2
0c9a6c1 Benjamin Steininger Init
authored
3 /**
4 * Robo47 Components
5 *
6 * LICENSE
7 *
8 * This source file is subject to the new BSD license that is bundled
9 * with this package in the file LICENSE.
10 * It is also available through the world-wide-web at this URL:
11 * http://robo47.net/licenses/new-bsd-license
12 * If you did not receive a copy of the license and are unable to
13 * obtain it through the world-wide-web, please send an email
14 * to robo47[at]robo47[dot]net so I can send you a copy immediately.
15 *
16 * @category Robo47
17 * @package Robo47
18 * @copyright Copyright (c) 2007-2010 Benjamin Steininger (http://robo47.net)
19 * @license http://robo47.net/licenses/new-bsd-license New BSD License
20 */
a79212b Benjamin Steininger prepare automated build alignment
authored
21
0c9a6c1 Benjamin Steininger Init
authored
22 /**
23 * Robo47_Mail_Transport_Multi
24 *
25 * @package Robo47
26 * @subpackage Mail
27 * @since 0.1
28 * @copyright Copyright (c) 2007-2010 Benjamin Steininger (http://robo47.net)
29 * @license http://robo47.net/licenses/new-bsd-license New BSD License
30 * @author Benjamin Steininger <robo47[at]robo47[dot]net>
31 */
32 class Robo47_Mail_Transport_Multi extends Zend_Mail_Transport_Abstract
33 {
d7a779f Benjamin Steininger Some code-formatting and minor additions
authored
34
0c9a6c1 Benjamin Steininger Init
authored
35 /**
36 * Array with all Transports
d7a779f Benjamin Steininger Some code-formatting and minor additions
authored
37 *
0c9a6c1 Benjamin Steininger Init
authored
38 * @var array
39 */
40 protected $_transports = array();
41
42 /**
43 * @param array|Zend_Mail_Transport_Abstract $transports
44 */
45 public function __construct($transports = array())
46 {
47 $this->setTransports($transports);
48 }
49
50 /**
51 * Set Transports
52 *
53 * @param array|Zend_Mail_Transport_Abstract $transports
54 * @return Robo47_Mail_Transport_Multi *Provides Fluent Interface*
55 */
56 public function setTransports($transports)
57 {
58 if (is_array($transports)) {
59 foreach ($transports as $transport) {
60 $this->addTransport($transport);
61 }
62 } else {
63 $this->addTransport($transports);
64 }
a79212b Benjamin Steininger prepare automated build alignment
authored
65
0c9a6c1 Benjamin Steininger Init
authored
66 return $this;
67 }
68
69 /**
70 * Add Transport
71 *
72 * @param Zend_Mail_Transport_Abstract $transport
73 * @return Robo47_Mail_Transport_Multi *Provides Fluent Interface*
74 */
75 public function addTransport(Zend_Mail_Transport_Abstract $transport)
76 {
77 $this->_transports[] = $transport;
a79212b Benjamin Steininger prepare automated build alignment
authored
78
0c9a6c1 Benjamin Steininger Init
authored
79 return $this;
80 }
81
82 /**
83 * Get Transports
84 *
85 * @return array
86 */
87 public function getTransports()
88 {
89 return $this->_transports;
90 }
91
92 /**
93 * Remove Transport
94 *
95 * @param string|mixed $class
96 * @return Robo47_Mail_Transport_Multi *Provides Fluent Interface*
97 */
98 public function removeTransport($class)
99 {
100 foreach ($this->_transports as $key => $transport) {
101 if (is_string($class)) {
102 if ($transport instanceof $class) {
103 unset($this->_transports[$key]);
104 }
105 } elseif (is_object($class)) {
106 if ($class === $transport) {
107 unset($this->_transports[$key]);
108 }
109 }
110 }
a79212b Benjamin Steininger prepare automated build alignment
authored
111
0c9a6c1 Benjamin Steininger Init
authored
112 return $this;
113 }
114
115 /**
116 * Send a mail using this transport
117 *
118 * @param Zend_Mail $mail
119 * @access public
120 * @return void
121 * @throws Zend_Mail_Transport_Exception if mail is empty
122 */
123 public function send(Zend_Mail $mail)
124 {
125 foreach ($this->_transports as $transport) {
126 /* @var $transport Zend_Mail_Transport_Abstract */
127 $transport->send($mail);
128 }
129 }
130
131 /**
132 * Not Really needed ... empty just to fullfil the requirements of the
133 * parent class
134 */
135 protected function _sendMail()
136 {
078295f Remove whitespace [Gun.io WhitespaceBot]
Gun.io Whitespace Robot authored
137
0c9a6c1 Benjamin Steininger Init
authored
138 }
a79212b Benjamin Steininger prepare automated build alignment
authored
139
0c9a6c1 Benjamin Steininger Init
authored
140 }
Something went wrong with that request. Please try again.