diff options
| author | Igor Wiedler <igor@wiedler.ch> | 2012-01-07 20:51:03 +0100 |
|---|---|---|
| committer | Igor Wiedler <igor@wiedler.ch> | 2012-01-07 20:51:03 +0100 |
| commit | 80840a5f08c530d91f147c1bded1c316c2a73d0f (patch) | |
| tree | e6052f0f1122e2991728d386fbab31ce34f65607 /phpBB/includes/event/event.php | |
| parent | 466acfdd943e37a3e1d98b12143894274fea9143 (diff) | |
| download | forums-80840a5f08c530d91f147c1bded1c316c2a73d0f.tar forums-80840a5f08c530d91f147c1bded1c316c2a73d0f.tar.gz forums-80840a5f08c530d91f147c1bded1c316c2a73d0f.tar.bz2 forums-80840a5f08c530d91f147c1bded1c316c2a73d0f.tar.xz forums-80840a5f08c530d91f147c1bded1c316c2a73d0f.zip | |
[feature/event-dispatcher] Introduce a port of Symfony2 EventDispatcher
PHPBB3-9550
Diffstat (limited to 'phpBB/includes/event/event.php')
| -rw-r--r-- | phpBB/includes/event/event.php | 123 |
1 files changed, 123 insertions, 0 deletions
diff --git a/phpBB/includes/event/event.php b/phpBB/includes/event/event.php new file mode 100644 index 0000000000..f74370618b --- /dev/null +++ b/phpBB/includes/event/event.php @@ -0,0 +1,123 @@ +<?php +/** +* +* @package phpBB3 +* @copyright (c) 2011 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* +*/ + +/** +* @ignore +*/ +if (!defined('IN_PHPBB')) +{ + exit; +} + +/** + * Event is the base class for classes containing event data. + * + * This class contains no event data. It is used by events that do not pass + * state information to an event handler when an event is raised. + * + * You can call the method stop_propagation() to abort the execution of + * further listeners in your event listener. + * + * @author Guilherme Blanco <guilhermeblanco@hotmail.com> + * @author Jonathan Wage <jonwage@gmail.com> + * @author Roman Borschel <roman@code-factory.org> + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class phpbb_event +{ + /** + * @var Boolean Whether no further event listeners should be triggered + */ + private $propagation_stopped = false; + + /** + * @var EventDispatcher Dispatcher that dispatched this event + */ + private $dispatcher; + + /** + * @var string This event's name + */ + private $name; + + /** + * Returns whether further event listeners should be triggered. + * + * @see Event::stop_propagation + * @return Boolean Whether propagation was already stopped for this event. + * + * @api + */ + public function is_propagation_stopped() + { + return $this->propagation_stopped; + } + + /** + * Stops the propagation of the event to further event listeners. + * + * If multiple event listeners are connected to the same event, no + * further event listener will be triggered once any trigger calls + * stop_propagation(). + * + * @api + */ + public function stop_propagation() + { + $this->propagation_stopped = true; + } + + /** + * Stores the EventDispatcher that dispatches this Event + * + * @param EventDispatcher $dispatcher + * + * @api + */ + public function set_dispatcher(phpbb_event_dispatcher $dispatcher) + { + $this->dispatcher = $dispatcher; + } + + /** + * Returns the EventDispatcher that dispatches this Event + * + * @return EventDispatcher + * + * @api + */ + public function get_dispatcher() + { + return $this->dispatcher; + } + + /** + * Gets the event's name. + * + * @return string + * + * @api + */ + public function get_name() + { + return $this->name; + } + + /** + * Sets the event's name property. + * + * @param string $name The event name. + * + * @api + */ + public function set_name($name) + { + $this->name = $name; + } +} |
