EventObject.php 1.3 KB

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