EventObject.php 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. /**
  10. * A base Event which all Event classes inherit from.
  11. *
  12. * @package Swift
  13. * @subpackage Events
  14. * @author Chris Corbyn
  15. */
  16. class Swift_Events_EventObject implements Swift_Events_Event
  17. {
  18. /** The source of this Event */
  19. private $_source;
  20. /** The state of this Event (should it bubble up the stack?) */
  21. private $_bubbleCancelled = false;
  22. /**
  23. * Create a new EventObject originating at $source.
  24. *
  25. * @param object $source
  26. */
  27. public function __construct($source)
  28. {
  29. $this->_source = $source;
  30. }
  31. /**
  32. * Get the source object of this event.
  33. *
  34. * @return object
  35. */
  36. public function getSource()
  37. {
  38. return $this->_source;
  39. }
  40. /**
  41. * Prevent this Event from bubbling any further up the stack.
  42. *
  43. * @param boolean $cancel, optional
  44. */
  45. public function cancelBubble($cancel = true)
  46. {
  47. $this->_bubbleCancelled = $cancel;
  48. }
  49. /**
  50. * Returns true if this Event will not bubble any further up the stack.
  51. *
  52. * @return boolean
  53. */
  54. public function bubbleCancelled()
  55. {
  56. return $this->_bubbleCancelled;
  57. }
  58. }