EventObject.php 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. * @param object $source
  25. */
  26. public function __construct($source)
  27. {
  28. $this->_source = $source;
  29. }
  30. /**
  31. * Get the source object of this event.
  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. * @param boolean $cancel, optional
  41. */
  42. public function cancelBubble($cancel = true)
  43. {
  44. $this->_bubbleCancelled = $cancel;
  45. }
  46. /**
  47. * Returns true if this Event will not bubble any further up the stack.
  48. * @return boolean
  49. */
  50. public function bubbleCancelled()
  51. {
  52. return $this->_bubbleCancelled;
  53. }
  54. }