/framework/vendor/swift/lib/classes/Swift/Events/SendEvent.php

http://zoop.googlecode.com/ · PHP · 127 lines · 43 code · 19 blank · 65 comment · 0 complexity · 3bd94b6f639b2ec5490542595165607e MD5 · raw file

  1. <?php
  2. /*
  3. * This file is part of SwiftMailer.
  4. * (c) 2004-2009 Chris Corbyn
  5. *
  6. * For the full copyright and license information, please view the LICENSE
  7. * file that was distributed with this source code.
  8. */
  9. //@require 'Swift/Events/EventObject.php';
  10. /**
  11. * Generated when a message is being sent.
  12. * @package Swift
  13. * @subpackage Events
  14. * @author Chris Corbyn
  15. */
  16. class Swift_Events_SendEvent extends Swift_Events_EventObject
  17. {
  18. /** Sending has yet to occur */
  19. const RESULT_PENDING = 0x0001;
  20. /** Sending was successful */
  21. const RESULT_SUCCESS = 0x0010;
  22. /** Sending worked, but there were some failures */
  23. const RESULT_TENTATIVE = 0x0100;
  24. /** Sending failed */
  25. const RESULT_FAILED = 0x1000;
  26. /**
  27. * The Message being sent.
  28. * @var Swift_Mime_Message
  29. */
  30. private $_message;
  31. /**
  32. * The Transport used in sending.
  33. * @var Swift_Transport
  34. */
  35. private $_transport;
  36. /**
  37. * Any recipients which failed after sending.
  38. * @var string[]
  39. */
  40. private $failedRecipients = array();
  41. /**
  42. * The overall result as a bitmask from the class constants.
  43. * @var int
  44. */
  45. private $result;
  46. /**
  47. * Create a new SendEvent for $source and $message.
  48. * @param Swift_Transport $source
  49. * @param Swift_Mime_Message $message
  50. */
  51. public function __construct(Swift_Transport $source,
  52. Swift_Mime_Message $message)
  53. {
  54. parent::__construct($source);
  55. $this->_message = $message;
  56. $this->_result = self::RESULT_PENDING;
  57. }
  58. /**
  59. * Get the Transport used to send the Message.
  60. * @return Swift_Transport
  61. */
  62. public function getTransport()
  63. {
  64. return $this->getSource();
  65. }
  66. /**
  67. * Get the Message being sent.
  68. * @return Swift_Mime_Message
  69. */
  70. public function getMessage()
  71. {
  72. return $this->_message;
  73. }
  74. /**
  75. * Set the array of addresses that failed in sending.
  76. * @param array $recipients
  77. */
  78. public function setFailedRecipients($recipients)
  79. {
  80. $this->_failedRecipients = $recipients;
  81. }
  82. /**
  83. * Get an recipient addresses which were not accepted for delivery.
  84. * @return string[]
  85. */
  86. public function getFailedRecipients()
  87. {
  88. return $this->_failedRecipients;
  89. }
  90. /**
  91. * Set the result of sending.
  92. * @return int
  93. */
  94. public function setResult($result)
  95. {
  96. $this->_result = $result;
  97. }
  98. /**
  99. * Get the result of this Event.
  100. * The return value is a bitmask from
  101. * {@link RESULT_PENDING, RESULT_SUCCESS, RESULT_TENTATIVE, RESULT_FAILED}
  102. * @return int
  103. */
  104. public function getResult()
  105. {
  106. return $this->_result;
  107. }
  108. }