1: <?php
2:
3: /*
4: * This file is part of SwiftMailer.
5: * (c) 2009 Fabien Potencier <fabien.potencier@gmail.com>
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: * Pretends messages have been sent, but just ignores them.
13: * @package Swift
14: * @author Fabien Potencier
15: */
16: class Swift_Transport_NullTransport implements Swift_Transport
17: {
18: /** The event dispatcher from the plugin API */
19: private $_eventDispatcher;
20:
21: /**
22: * Constructor.
23: */
24: public function __construct(Swift_Events_EventDispatcher $eventDispatcher)
25: {
26: $this->_eventDispatcher = $eventDispatcher;
27: }
28:
29: /**
30: * Tests if this Transport mechanism has started.
31: *
32: * @return boolean
33: */
34: public function isStarted()
35: {
36: return true;
37: }
38:
39: /**
40: * Starts this Transport mechanism.
41: */
42: public function start()
43: {
44: }
45:
46: /**
47: * Stops this Transport mechanism.
48: */
49: public function stop()
50: {
51: }
52:
53: /**
54: * Sends the given message.
55: *
56: * @param Swift_Mime_Message $message
57: * @param string[] &$failedRecipients to collect failures by-reference
58: *
59: * @return int The number of sent emails
60: */
61: public function send(Swift_Mime_Message $message, &$failedRecipients = null)
62: {
63: if ($evt = $this->_eventDispatcher->createSendEvent($this, $message)) {
64: $this->_eventDispatcher->dispatchEvent($evt, 'beforeSendPerformed');
65: if ($evt->bubbleCancelled()) {
66: return 0;
67: }
68: }
69:
70: if ($evt) {
71: $evt->setResult(Swift_Events_SendEvent::RESULT_SUCCESS);
72: $this->_eventDispatcher->dispatchEvent($evt, 'sendPerformed');
73: }
74:
75: return 0;
76: }
77:
78: /**
79: * Register a plugin.
80: *
81: * @param Swift_Events_EventListener $plugin
82: */
83: public function registerPlugin(Swift_Events_EventListener $plugin)
84: {
85: $this->_eventDispatcher->bindEventListener($plugin);
86: }
87: }
88: