EventObject.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. public function cancelBubble($cancel = true)
  42. {
  43. $this->bubbleCancelled = $cancel;
  44. }
  45. /**
  46. * Returns true if this Event will not bubble any further up the stack.
  47. *
  48. * @return bool
  49. */
  50. public function bubbleCancelled()
  51. {
  52. return $this->bubbleCancelled;
  53. }
  54. }