From 80840a5f08c530d91f147c1bded1c316c2a73d0f Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 7 Jan 2012 20:51:03 +0100 Subject: [PATCH 01/29] [feature/event-dispatcher] Introduce a port of Symfony2 EventDispatcher PHPBB3-9550 --- phpBB/includes/event/dispatcher.php | 185 ++++++++++++++++++ phpBB/includes/event/dispatcher_interface.php | 96 +++++++++ phpBB/includes/event/event.php | 123 ++++++++++++ phpBB/includes/event/subscriber_interface.php | 50 +++++ 4 files changed, 454 insertions(+) create mode 100644 phpBB/includes/event/dispatcher.php create mode 100644 phpBB/includes/event/dispatcher_interface.php create mode 100644 phpBB/includes/event/event.php create mode 100644 phpBB/includes/event/subscriber_interface.php diff --git a/phpBB/includes/event/dispatcher.php b/phpBB/includes/event/dispatcher.php new file mode 100644 index 0000000000..c3b8dc5790 --- /dev/null +++ b/phpBB/includes/event/dispatcher.php @@ -0,0 +1,185 @@ + + * @author Jonathan Wage + * @author Roman Borschel + * @author Bernhard Schussek + * @author Fabien Potencier + * @author Jordi Boggiano + * @author Jordan Alliot + */ +class phpbb_event_dispatcher +{ + private $listeners = array(); + private $sorted = array(); + + /** + * @see EventDispatcherInterface::dispatch + * + * @api + */ + public function dispatch($event_name, phpbb_event $event = null) + { + if (!isset($this->listeners[$event_name])) { + return; + } + + if (null === $event) { + $event = new phpbb_event(); + } + + $event->set_dispatcher($this); + $event->set_name($event_name); + + $this->do_dispatch($this->get_listeners($event_name), $event_name, $event); + } + + /** + * @see EventDispatcherInterface::get_listeners + */ + public function get_listeners($event_name = null) + { + if (null !== $event_name) { + if (!isset($this->sorted[$event_name])) { + $this->sort_listeners($event_name); + } + + return $this->sorted[$event_name]; + } + + foreach (array_keys($this->listeners) as $event_name) { + if (!isset($this->sorted[$event_name])) { + $this->sort_listeners($event_name); + } + } + + return $this->sorted; + } + + /** + * @see EventDispatcherInterface::has_listeners + */ + public function has_listeners($event_name = null) + { + return (Boolean) count($this->get_listeners($event_name)); + } + + /** + * @see EventDispatcherInterface::add_listener + * + * @api + */ + public function add_listener($event_name, $listener, $priority = 0) + { + $this->listeners[$event_name][$priority][] = $listener; + unset($this->sorted[$event_name]); + } + + /** + * @see EventDispatcherInterface::remove_listener + */ + public function remove_listener($event_name, $listener) + { + if (!isset($this->listeners[$event_name])) { + return; + } + + foreach ($this->listeners[$event_name] as $priority => $listeners) { + if (false !== ($key = array_search($listener, $listeners))) { + unset($this->listeners[$event_name][$priority][$key], $this->sorted[$event_name]); + } + } + } + + /** + * @see EventDispatcherInterface::add_subscriber + * + * @api + */ + public function add_subscriber(phpbb_event_subscriber_interface $subscriber) + { + foreach ($subscriber->get_subscribed_events() as $event_name => $params) { + if (is_string($params)) { + $this->add_listener($event_name, array($subscriber, $params)); + } elseif (is_string($params[0])) { + $this->add_listener($event_name, array($subscriber, $params[0]), $params[1]); + } else { + foreach ($params as $listener) { + $this->add_listener($event_name, array($subscriber, $listener[0]), isset($listener[1]) ? $listener[1] : 0); + } + } + } + } + + /** + * @see EventDispatcherInterface::remove_subscriber + */ + public function remove_subscriber(phpbb_event_subscriber_interface $subscriber) + { + foreach ($subscriber->get_subscribed_events() as $event_name => $params) { + if (is_array($params) && is_array($params[0])) { + foreach ($params as $listener) { + $this->remove_listener($event_name, array($subscriber, $listener[0])); + } + } else { + $this->remove_listener($event_name, array($subscriber, is_string($params) ? $params : $params[0])); + } + } + } + + /** + * Triggers the listeners of an event. + * + * This method can be overridden to add functionality that is executed + * for each listener. + * + * @param array[callback] $listeners The event listeners. + * @param string $event_name The name of the event to dispatch. + * @param Event $event The event object to pass to the event handlers/listeners. + */ + protected function do_dispatch($listeners, $event_name, phpbb_event $event) + { + foreach ($listeners as $listener) { + call_user_func($listener, $event); + if ($event->is_propagation_stopped()) { + break; + } + } + } + + /** + * Sorts the internal list of listeners for the given event by priority. + * + * @param string $event_name The name of the event. + */ + private function sort_listeners($event_name) + { + $this->sorted[$event_name] = array(); + + if (isset($this->listeners[$event_name])) { + krsort($this->listeners[$event_name]); + $this->sorted[$event_name] = call_user_func_array('array_merge', $this->listeners[$event_name]); + } + } +} diff --git a/phpBB/includes/event/dispatcher_interface.php b/phpBB/includes/event/dispatcher_interface.php new file mode 100644 index 0000000000..2564591ed7 --- /dev/null +++ b/phpBB/includes/event/dispatcher_interface.php @@ -0,0 +1,96 @@ + + */ +interface phpbb_event_dispatcher_interface +{ + /** + * Dispatches an event to all registered listeners. + * + * @param string $event_name The name of the event to dispatch. The name of + * the event is the name of the method that is + * invoked on listeners. + * @param Event $event The event to pass to the event handlers/listeners. + * If not supplied, an empty Event instance is created. + * + * @api + */ + function dispatch($event_name, Event $event = null); + + /** + * Adds an event listener that listens on the specified events. + * + * @param string $event_name The event to listen on + * @param callable $listener The listener + * @param integer $priority The higher this value, the earlier an event + * listener will be triggered in the chain (defaults to 0) + * + * @api + */ + function add_listener($event_name, $listener, $priority = 0); + + /** + * Adds an event subscriber. The subscriber is asked for all the events he is + * interested in and added as a listener for these events. + * + * @param EventSubscriberInterface $subscriber The subscriber. + * + * @api + */ + function add_subscriber(phpbb_event_subscriber_interface $subscriber); + + /** + * Removes an event listener from the specified events. + * + * @param string|array $event_name The event(s) to remove a listener from. + * @param object $listener The listener object to remove. + */ + function remove_listener($event_name, $listener); + + /** + * Removes an event subscriber. + * + * @param EventSubscriberInterface $subscriber The subscriber. + */ + function remove_subscriber(phpbb_event_subscriber_interface $subscriber); + + /** + * Gets the listeners of a specific event or all listeners. + * + * @param string $event_name The name of the event. + * + * @return array The event listeners for the specified event, or all event + * listeners by event name. + */ + function get_listeners($event_name = null); + + /** + * Checks whether an event has any registered listeners. + * + * @param string $event_name The name of the event. + * + * @return Boolean TRUE if the specified event has any listeners, FALSE + * otherwise. + */ + function has_listeners($event_name = null); +} 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 @@ + + * @author Jonathan Wage + * @author Roman Borschel + * @author Bernhard Schussek + */ +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; + } +} diff --git a/phpBB/includes/event/subscriber_interface.php b/phpBB/includes/event/subscriber_interface.php new file mode 100644 index 0000000000..4e7b23f596 --- /dev/null +++ b/phpBB/includes/event/subscriber_interface.php @@ -0,0 +1,50 @@ + + * @author Jonathan Wage + * @author Roman Borschel + * @author Bernhard Schussek + */ +interface phpbb_event_subscriber_interface +{ + /** + * Returns an array of event names this subscriber wants to listen to. + * + * The array keys are event names and the value can be: + * + * * The method name to call (priority defaults to 0) + * * An array composed of the method name to call and the priority + * * An array of arrays composed of the method names to call and respective + * priorities, or 0 if unset + * + * For instance: + * + * * array('event_name' => 'method_name') + * * array('event_name' => array('method_name', $priority)) + * * array('event_name' => array(array('method_name1', $priority), array('method_name2')) + * + * @return array The event names to listen to + */ + static function get_subscribed_events(); +} From 581b5624f7be3675a35fc61ca6b67b409ae6e8c6 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 7 Jan 2012 20:53:04 +0100 Subject: [PATCH 02/29] [feature/event-dispatcher] Allow subscribers to be loaded from extensions PHPBB3-9550 --- phpBB/common.php | 4 ++ .../event/extension_subscriber_loader.php | 43 +++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 phpBB/includes/event/extension_subscriber_loader.php diff --git a/phpBB/common.php b/phpBB/common.php index b308037a0e..44a0e7cec3 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -98,6 +98,7 @@ $phpbb_class_loader_ext->set_cache($cache->get_driver()); $phpbb_class_loader->set_cache($cache->get_driver()); // Instantiate some basic classes +$phpbb_dispatcher = new phpbb_event_dispatcher(); $request = new phpbb_request(); $user = new user(); $auth = new auth(); @@ -124,6 +125,9 @@ $phpbb_template_locator = new phpbb_template_locator(); $phpbb_template_path_provider = new phpbb_template_extension_path_provider($phpbb_extension_manager, new phpbb_template_path_provider()); $template = new phpbb_template($phpbb_root_path, $phpEx, $config, $user, $phpbb_template_locator, $phpbb_template_path_provider); +$phpbb_subscriber_loader = new phpbb_event_extension_subscriber_loader($phpbb_dispatcher, $phpbb_extension_manager); +$phpbb_subscriber_loader->load(); + // Add own hook handler require($phpbb_root_path . 'includes/hooks/index.' . $phpEx); $phpbb_hook = new phpbb_hook(array('exit_handler', 'phpbb_user_session_handler', 'append_sid', array('template', 'display'))); diff --git a/phpBB/includes/event/extension_subscriber_loader.php b/phpBB/includes/event/extension_subscriber_loader.php new file mode 100644 index 0000000000..2a53af1249 --- /dev/null +++ b/phpBB/includes/event/extension_subscriber_loader.php @@ -0,0 +1,43 @@ +dispatcher = $dispatcher; + $this->extension_manager = $extension_manager; + } + + public function load() + { + $finder = $this->extension_manager->get_finder(); + $subscriber_classes = $finder + ->extension_directory('/event') + ->suffix('subscriber') + ->core_path('event/') + ->get_classes(); + + foreach ($subscriber_classes as $class) { + $subscriber = new $class(); + $this->dispatcher->add_subscriber($subscriber); + } + } +} From 58a99c97cadd6a16b138e4de4f8fd1aa172e4eed Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 7 Jan 2012 20:54:01 +0100 Subject: [PATCH 03/29] [feature/event-dispatcher] Add a sample hook in page_header PHPBB3-9550 --- phpBB/includes/functions.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 753795b7cf..03376bf906 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4461,6 +4461,7 @@ function phpbb_http_login($param) function page_header($page_title = '', $display_online_list = true, $item_id = 0, $item = 'forum') { global $db, $config, $template, $SID, $_SID, $_EXTRA_URL, $user, $auth, $phpEx, $phpbb_root_path; + global $phpbb_dispatcher; if (defined('HEADER_INC')) { @@ -4744,6 +4745,9 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 'A_COOKIE_SETTINGS' => addslashes('; path=' . $config['cookie_path'] . ((!$config['cookie_domain'] || $config['cookie_domain'] == 'localhost' || $config['cookie_domain'] == '127.0.0.1') ? '' : '; domain=' . $config['cookie_domain']) . ((!$config['cookie_secure']) ? '' : '; secure')), )); + $event = new phpbb_event(); + $phpbb_dispatcher->dispatch('page_header', $event); + // application/xhtml+xml not used because of IE header('Content-type: text/html; charset=UTF-8'); From 03be9761375a082c2a43aceaa1b34661f87d702b Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 7 Jan 2012 21:42:19 +0100 Subject: [PATCH 04/29] [feature/event-dispatcher] Support setting data on an event PHPBB3-9550 --- phpBB/includes/event/data.php | 56 +++++++++++++++++++++++++++++++++++ phpBB/includes/functions.php | 3 +- 2 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 phpBB/includes/event/data.php diff --git a/phpBB/includes/event/data.php b/phpBB/includes/event/data.php new file mode 100644 index 0000000000..754876c119 --- /dev/null +++ b/phpBB/includes/event/data.php @@ -0,0 +1,56 @@ +set_data($data); + } + + public function set_data(array $data = array()) + { + $this->data = $data; + } + + public function get_data() + { + return $this->data; + } + + public function offsetExists($offset) + { + return isset($this->data[$offset]); + } + + public function offsetGet($offset) + { + return isset($this->data[$offset]) ? $this->data[$offset] : null; + } + + public function offsetSet($offset, $value) + { + $this->data[$offset] = $value; + } + + public function offsetUnset($offset) + { + unset($this->data[$offset]); + } +} diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 03376bf906..109f5b0366 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4745,7 +4745,8 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 'A_COOKIE_SETTINGS' => addslashes('; path=' . $config['cookie_path'] . ((!$config['cookie_domain'] || $config['cookie_domain'] == 'localhost' || $config['cookie_domain'] == '127.0.0.1') ? '' : '; domain=' . $config['cookie_domain']) . ((!$config['cookie_secure']) ? '' : '; secure')), )); - $event = new phpbb_event(); + $event = new phpbb_event_data(); + $event->set_data(compact('page_title', 'display_online_list', 'item_id', 'item')); $phpbb_dispatcher->dispatch('page_header', $event); // application/xhtml+xml not used because of IE From 80f6f2b96f1ef0c3a3bf5637cac85a3c1fa229db Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 7 Jan 2012 21:50:16 +0100 Subject: [PATCH 05/29] [feature/event-dispatcher] Prefix event name with 'core.' PHPBB3-9550 --- phpBB/includes/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 109f5b0366..45958d1a0d 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4747,7 +4747,7 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 $event = new phpbb_event_data(); $event->set_data(compact('page_title', 'display_online_list', 'item_id', 'item')); - $phpbb_dispatcher->dispatch('page_header', $event); + $phpbb_dispatcher->dispatch('core.page_header', $event); // application/xhtml+xml not used because of IE header('Content-type: text/html; charset=UTF-8'); From 82422968796188d4284d7cba0f837ee8f333bf11 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sun, 8 Jan 2012 00:48:21 +0100 Subject: [PATCH 06/29] [feature/event-dispatcher] Fix event class name in dispatcher interface PHPBB3-9550 --- phpBB/includes/event/dispatcher_interface.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/event/dispatcher_interface.php b/phpBB/includes/event/dispatcher_interface.php index 2564591ed7..0a4881b3ba 100644 --- a/phpBB/includes/event/dispatcher_interface.php +++ b/phpBB/includes/event/dispatcher_interface.php @@ -35,7 +35,7 @@ interface phpbb_event_dispatcher_interface * * @api */ - function dispatch($event_name, Event $event = null); + function dispatch($event_name, phpbb_event $event = null); /** * Adds an event listener that listens on the specified events. From 71c5eddb7194f25711bc0733a54f09bf2f0c7c06 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sun, 8 Jan 2012 01:01:11 +0100 Subject: [PATCH 07/29] [feature/event-dispatcher] Add Symfony2 to AUTHORS PHPBB3-9550 --- phpBB/docs/AUTHORS | 3 +++ 1 file changed, 3 insertions(+) diff --git a/phpBB/docs/AUTHORS b/phpBB/docs/AUTHORS index 4fe0af6e28..8be261706e 100644 --- a/phpBB/docs/AUTHORS +++ b/phpBB/docs/AUTHORS @@ -79,3 +79,6 @@ Pear (c) 2001-2004 PHP Group, http://pear.php.net Text_Diff-0.2.1 http://pear.php.net/package/Text_Diff +MIT licenced: +Symfony2 (c) 2004-2011 Fabien Potencier, http://symfony.com/ + From 4c62dcd0ffc36a1c4bea203d7dcabbdd1f6143a3 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sun, 8 Jan 2012 13:20:44 +0100 Subject: [PATCH 08/29] [feature/event-dispatcher] Correct copyright statement for Symfony2 files Also add a notice to the files that were taken from Symfony2. PHPBB3-9550 --- phpBB/includes/event/dispatcher.php | 7 ++++++- phpBB/includes/event/dispatcher_interface.php | 7 ++++++- phpBB/includes/event/event.php | 7 ++++++- phpBB/includes/event/subscriber_interface.php | 7 ++++++- 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/phpBB/includes/event/dispatcher.php b/phpBB/includes/event/dispatcher.php index c3b8dc5790..6f7d61c83b 100644 --- a/phpBB/includes/event/dispatcher.php +++ b/phpBB/includes/event/dispatcher.php @@ -2,7 +2,7 @@ /** * * @package phpBB3 -* @copyright (c) 2011 phpBB Group +* @copyright (c) Fabien Potencier * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ @@ -15,6 +15,11 @@ if (!defined('IN_PHPBB')) exit; } +/** + * This file has been taken from Symfony2 and adjusted for + * phpBB's coding standards. + */ + /** * The EventDispatcherInterface is the central point of Symfony's event listener system. * diff --git a/phpBB/includes/event/dispatcher_interface.php b/phpBB/includes/event/dispatcher_interface.php index 0a4881b3ba..37e6bd4cf1 100644 --- a/phpBB/includes/event/dispatcher_interface.php +++ b/phpBB/includes/event/dispatcher_interface.php @@ -2,7 +2,7 @@ /** * * @package phpBB3 -* @copyright (c) 2011 phpBB Group +* @copyright (c) Fabien Potencier * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ @@ -15,6 +15,11 @@ if (!defined('IN_PHPBB')) exit; } +/** + * This file has been taken from Symfony2 and adjusted for + * phpBB's coding standards. + */ + /** * The EventDispatcherInterface is the central point of Symfony's event listener system. * Listeners are registered on the manager and events are dispatched through the diff --git a/phpBB/includes/event/event.php b/phpBB/includes/event/event.php index f74370618b..6ee144bc68 100644 --- a/phpBB/includes/event/event.php +++ b/phpBB/includes/event/event.php @@ -2,7 +2,7 @@ /** * * @package phpBB3 -* @copyright (c) 2011 phpBB Group +* @copyright (c) Fabien Potencier * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ @@ -15,6 +15,11 @@ if (!defined('IN_PHPBB')) exit; } +/** + * This file has been taken from Symfony2 and adjusted for + * phpBB's coding standards. + */ + /** * Event is the base class for classes containing event data. * diff --git a/phpBB/includes/event/subscriber_interface.php b/phpBB/includes/event/subscriber_interface.php index 4e7b23f596..081d4f0210 100644 --- a/phpBB/includes/event/subscriber_interface.php +++ b/phpBB/includes/event/subscriber_interface.php @@ -2,7 +2,7 @@ /** * * @package phpBB3 -* @copyright (c) 2011 phpBB Group +* @copyright (c) Fabien Potencier * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ @@ -15,6 +15,11 @@ if (!defined('IN_PHPBB')) exit; } +/** + * This file has been taken from Symfony2 and adjusted for + * phpBB's coding standards. + */ + /** * An EventSubscriber knows himself what events he is interested in. * If an EventSubscriber is added to an EventDispatcherInterface, the manager invokes From 5dd5df46a497631b905f6595707b0d1b0c302749 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sun, 11 Mar 2012 14:55:01 +0100 Subject: [PATCH 09/29] [feature/event-dispatcher] Remove copied EventDispatcher code PHPBB3-9550 --- phpBB/includes/event/dispatcher.php | 190 ------------------ phpBB/includes/event/dispatcher_interface.php | 101 ---------- phpBB/includes/event/event.php | 128 ------------ phpBB/includes/event/subscriber_interface.php | 55 ----- 4 files changed, 474 deletions(-) delete mode 100644 phpBB/includes/event/dispatcher.php delete mode 100644 phpBB/includes/event/dispatcher_interface.php delete mode 100644 phpBB/includes/event/event.php delete mode 100644 phpBB/includes/event/subscriber_interface.php diff --git a/phpBB/includes/event/dispatcher.php b/phpBB/includes/event/dispatcher.php deleted file mode 100644 index 6f7d61c83b..0000000000 --- a/phpBB/includes/event/dispatcher.php +++ /dev/null @@ -1,190 +0,0 @@ - -* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -/** - * This file has been taken from Symfony2 and adjusted for - * phpBB's coding standards. - */ - -/** - * The EventDispatcherInterface is the central point of Symfony's event listener system. - * - * Listeners are registered on the manager and events are dispatched through the - * manager. - * - * @author Guilherme Blanco - * @author Jonathan Wage - * @author Roman Borschel - * @author Bernhard Schussek - * @author Fabien Potencier - * @author Jordi Boggiano - * @author Jordan Alliot - */ -class phpbb_event_dispatcher -{ - private $listeners = array(); - private $sorted = array(); - - /** - * @see EventDispatcherInterface::dispatch - * - * @api - */ - public function dispatch($event_name, phpbb_event $event = null) - { - if (!isset($this->listeners[$event_name])) { - return; - } - - if (null === $event) { - $event = new phpbb_event(); - } - - $event->set_dispatcher($this); - $event->set_name($event_name); - - $this->do_dispatch($this->get_listeners($event_name), $event_name, $event); - } - - /** - * @see EventDispatcherInterface::get_listeners - */ - public function get_listeners($event_name = null) - { - if (null !== $event_name) { - if (!isset($this->sorted[$event_name])) { - $this->sort_listeners($event_name); - } - - return $this->sorted[$event_name]; - } - - foreach (array_keys($this->listeners) as $event_name) { - if (!isset($this->sorted[$event_name])) { - $this->sort_listeners($event_name); - } - } - - return $this->sorted; - } - - /** - * @see EventDispatcherInterface::has_listeners - */ - public function has_listeners($event_name = null) - { - return (Boolean) count($this->get_listeners($event_name)); - } - - /** - * @see EventDispatcherInterface::add_listener - * - * @api - */ - public function add_listener($event_name, $listener, $priority = 0) - { - $this->listeners[$event_name][$priority][] = $listener; - unset($this->sorted[$event_name]); - } - - /** - * @see EventDispatcherInterface::remove_listener - */ - public function remove_listener($event_name, $listener) - { - if (!isset($this->listeners[$event_name])) { - return; - } - - foreach ($this->listeners[$event_name] as $priority => $listeners) { - if (false !== ($key = array_search($listener, $listeners))) { - unset($this->listeners[$event_name][$priority][$key], $this->sorted[$event_name]); - } - } - } - - /** - * @see EventDispatcherInterface::add_subscriber - * - * @api - */ - public function add_subscriber(phpbb_event_subscriber_interface $subscriber) - { - foreach ($subscriber->get_subscribed_events() as $event_name => $params) { - if (is_string($params)) { - $this->add_listener($event_name, array($subscriber, $params)); - } elseif (is_string($params[0])) { - $this->add_listener($event_name, array($subscriber, $params[0]), $params[1]); - } else { - foreach ($params as $listener) { - $this->add_listener($event_name, array($subscriber, $listener[0]), isset($listener[1]) ? $listener[1] : 0); - } - } - } - } - - /** - * @see EventDispatcherInterface::remove_subscriber - */ - public function remove_subscriber(phpbb_event_subscriber_interface $subscriber) - { - foreach ($subscriber->get_subscribed_events() as $event_name => $params) { - if (is_array($params) && is_array($params[0])) { - foreach ($params as $listener) { - $this->remove_listener($event_name, array($subscriber, $listener[0])); - } - } else { - $this->remove_listener($event_name, array($subscriber, is_string($params) ? $params : $params[0])); - } - } - } - - /** - * Triggers the listeners of an event. - * - * This method can be overridden to add functionality that is executed - * for each listener. - * - * @param array[callback] $listeners The event listeners. - * @param string $event_name The name of the event to dispatch. - * @param Event $event The event object to pass to the event handlers/listeners. - */ - protected function do_dispatch($listeners, $event_name, phpbb_event $event) - { - foreach ($listeners as $listener) { - call_user_func($listener, $event); - if ($event->is_propagation_stopped()) { - break; - } - } - } - - /** - * Sorts the internal list of listeners for the given event by priority. - * - * @param string $event_name The name of the event. - */ - private function sort_listeners($event_name) - { - $this->sorted[$event_name] = array(); - - if (isset($this->listeners[$event_name])) { - krsort($this->listeners[$event_name]); - $this->sorted[$event_name] = call_user_func_array('array_merge', $this->listeners[$event_name]); - } - } -} diff --git a/phpBB/includes/event/dispatcher_interface.php b/phpBB/includes/event/dispatcher_interface.php deleted file mode 100644 index 37e6bd4cf1..0000000000 --- a/phpBB/includes/event/dispatcher_interface.php +++ /dev/null @@ -1,101 +0,0 @@ - -* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -/** - * This file has been taken from Symfony2 and adjusted for - * phpBB's coding standards. - */ - -/** - * The EventDispatcherInterface is the central point of Symfony's event listener system. - * Listeners are registered on the manager and events are dispatched through the - * manager. - * - * @author Bernhard Schussek - */ -interface phpbb_event_dispatcher_interface -{ - /** - * Dispatches an event to all registered listeners. - * - * @param string $event_name The name of the event to dispatch. The name of - * the event is the name of the method that is - * invoked on listeners. - * @param Event $event The event to pass to the event handlers/listeners. - * If not supplied, an empty Event instance is created. - * - * @api - */ - function dispatch($event_name, phpbb_event $event = null); - - /** - * Adds an event listener that listens on the specified events. - * - * @param string $event_name The event to listen on - * @param callable $listener The listener - * @param integer $priority The higher this value, the earlier an event - * listener will be triggered in the chain (defaults to 0) - * - * @api - */ - function add_listener($event_name, $listener, $priority = 0); - - /** - * Adds an event subscriber. The subscriber is asked for all the events he is - * interested in and added as a listener for these events. - * - * @param EventSubscriberInterface $subscriber The subscriber. - * - * @api - */ - function add_subscriber(phpbb_event_subscriber_interface $subscriber); - - /** - * Removes an event listener from the specified events. - * - * @param string|array $event_name The event(s) to remove a listener from. - * @param object $listener The listener object to remove. - */ - function remove_listener($event_name, $listener); - - /** - * Removes an event subscriber. - * - * @param EventSubscriberInterface $subscriber The subscriber. - */ - function remove_subscriber(phpbb_event_subscriber_interface $subscriber); - - /** - * Gets the listeners of a specific event or all listeners. - * - * @param string $event_name The name of the event. - * - * @return array The event listeners for the specified event, or all event - * listeners by event name. - */ - function get_listeners($event_name = null); - - /** - * Checks whether an event has any registered listeners. - * - * @param string $event_name The name of the event. - * - * @return Boolean TRUE if the specified event has any listeners, FALSE - * otherwise. - */ - function has_listeners($event_name = null); -} diff --git a/phpBB/includes/event/event.php b/phpBB/includes/event/event.php deleted file mode 100644 index 6ee144bc68..0000000000 --- a/phpBB/includes/event/event.php +++ /dev/null @@ -1,128 +0,0 @@ - -* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -/** - * This file has been taken from Symfony2 and adjusted for - * phpBB's coding standards. - */ - -/** - * 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 - * @author Jonathan Wage - * @author Roman Borschel - * @author Bernhard Schussek - */ -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; - } -} diff --git a/phpBB/includes/event/subscriber_interface.php b/phpBB/includes/event/subscriber_interface.php deleted file mode 100644 index 081d4f0210..0000000000 --- a/phpBB/includes/event/subscriber_interface.php +++ /dev/null @@ -1,55 +0,0 @@ - -* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -/** - * This file has been taken from Symfony2 and adjusted for - * phpBB's coding standards. - */ - -/** - * An EventSubscriber knows himself what events he is interested in. - * If an EventSubscriber is added to an EventDispatcherInterface, the manager invokes - * {@link get_subscribed_events} and registers the subscriber as a listener for all - * returned events. - * - * @author Guilherme Blanco - * @author Jonathan Wage - * @author Roman Borschel - * @author Bernhard Schussek - */ -interface phpbb_event_subscriber_interface -{ - /** - * Returns an array of event names this subscriber wants to listen to. - * - * The array keys are event names and the value can be: - * - * * The method name to call (priority defaults to 0) - * * An array composed of the method name to call and the priority - * * An array of arrays composed of the method names to call and respective - * priorities, or 0 if unset - * - * For instance: - * - * * array('event_name' => 'method_name') - * * array('event_name' => array('method_name', $priority)) - * * array('event_name' => array(array('method_name1', $priority), array('method_name2')) - * - * @return array The event names to listen to - */ - static function get_subscribed_events(); -} From e02d92ac62fbe1dc08994444c18a7447d72c56e6 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sun, 11 Mar 2012 15:14:13 +0100 Subject: [PATCH 10/29] [feature/event-dispatcher] Use real EventDispatcher through composer * replace the copy-pasta EventDispatcher with the real one from Symfony2 * use composer for managing this dependency, use composer autoloading PHPBB3-9550 --- .gitignore | 1 + phpBB/common.php | 6 +++++- phpBB/composer.json | 5 +++++ phpBB/composer.lock | 10 ++++++++++ phpBB/download/file.php | 2 ++ phpBB/includes/event/data.php | 4 +++- phpBB/includes/event/extension_subscriber_loader.php | 6 ++++-- phpBB/install/database_update.php | 2 ++ phpBB/install/index.php | 2 ++ tests/bootstrap.php | 2 ++ 10 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 phpBB/composer.json create mode 100644 phpBB/composer.lock diff --git a/.gitignore b/.gitignore index 1ac01d9b2d..542527e717 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ /phpBB/images/avatars/gallery/* /phpBB/images/avatars/upload/* /phpBB/store/* +/phpBB/vendor /tests/phpbb_unit_tests.sqlite2 /tests/test_config.php /tests/tmp/* diff --git a/phpBB/common.php b/phpBB/common.php index 44a0e7cec3..c48418276a 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -15,6 +15,8 @@ if (!defined('IN_PHPBB')) exit; } +use Symfony\Component\EventDispatcher\EventDispatcher; + require($phpbb_root_path . 'includes/startup.' . $phpEx); if (file_exists($phpbb_root_path . 'config.' . $phpEx)) @@ -70,6 +72,8 @@ if (!empty($load_extensions) && function_exists('dl')) } } +require($phpbb_root_path . 'vendor/.composer/autoload.php'); + // Include files require($phpbb_root_path . 'includes/class_loader.' . $phpEx); require($phpbb_root_path . 'includes/session.' . $phpEx); @@ -98,7 +102,7 @@ $phpbb_class_loader_ext->set_cache($cache->get_driver()); $phpbb_class_loader->set_cache($cache->get_driver()); // Instantiate some basic classes -$phpbb_dispatcher = new phpbb_event_dispatcher(); +$phpbb_dispatcher = new EventDispatcher(); $request = new phpbb_request(); $user = new user(); $auth = new auth(); diff --git a/phpBB/composer.json b/phpBB/composer.json new file mode 100644 index 0000000000..1059b97f84 --- /dev/null +++ b/phpBB/composer.json @@ -0,0 +1,5 @@ +{ + "require": { + "symfony/event-dispatcher": "2.0.*" + } +} diff --git a/phpBB/composer.lock b/phpBB/composer.lock new file mode 100644 index 0000000000..062ad4b3aa --- /dev/null +++ b/phpBB/composer.lock @@ -0,0 +1,10 @@ +{ + "hash": "9bada3748ec2933fe0864dcfafbcd671", + "packages": [ + { + "package": "symfony/event-dispatcher", + "version": "v2.0.10" + } + ], + "aliases": [] +} diff --git a/phpBB/download/file.php b/phpBB/download/file.php index 2baa9d6c8a..3f14a9cb82 100644 --- a/phpBB/download/file.php +++ b/phpBB/download/file.php @@ -38,6 +38,8 @@ if (isset($_GET['avatar'])) exit; } + require($phpbb_root_path . 'vendor/.composer/autoload.php'); + require($phpbb_root_path . 'includes/class_loader.' . $phpEx); require($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx); require($phpbb_root_path . 'includes/constants.' . $phpEx); diff --git a/phpBB/includes/event/data.php b/phpBB/includes/event/data.php index 754876c119..62e2f2312e 100644 --- a/phpBB/includes/event/data.php +++ b/phpBB/includes/event/data.php @@ -15,7 +15,9 @@ if (!defined('IN_PHPBB')) exit; } -class phpbb_event_data extends phpbb_event implements ArrayAccess +use Symfony\Component\EventDispatcher\Event; + +class phpbb_event_data extends Event implements ArrayAccess { private $data; diff --git a/phpBB/includes/event/extension_subscriber_loader.php b/phpBB/includes/event/extension_subscriber_loader.php index 2a53af1249..aa32ca9686 100644 --- a/phpBB/includes/event/extension_subscriber_loader.php +++ b/phpBB/includes/event/extension_subscriber_loader.php @@ -15,12 +15,14 @@ if (!defined('IN_PHPBB')) exit; } +use Symfony\Component\EventDispatcher\EventDispatcher; + class phpbb_event_extension_subscriber_loader { private $dispatcher; private $extension_manager; - public function __construct(phpbb_event_dispatcher $dispatcher, phpbb_extension_manager $extension_manager) + public function __construct(EventDispatcher $dispatcher, phpbb_extension_manager $extension_manager) { $this->dispatcher = $dispatcher; $this->extension_manager = $extension_manager; @@ -37,7 +39,7 @@ class phpbb_event_extension_subscriber_loader foreach ($subscriber_classes as $class) { $subscriber = new $class(); - $this->dispatcher->add_subscriber($subscriber); + $this->dispatcher->addSubscriber($subscriber); } } } diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 843e8c2f23..a1c8fe1ef9 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -82,6 +82,8 @@ if (!empty($load_extensions) && function_exists('dl')) } } +require($phpbb_root_path . 'vendor/.composer/autoload.php'); + // Include files require($phpbb_root_path . 'includes/class_loader.' . $phpEx); require($phpbb_root_path . 'includes/session.' . $phpEx); diff --git a/phpBB/install/index.php b/phpBB/install/index.php index 9d003ba6ab..7e150c2519 100644 --- a/phpBB/install/index.php +++ b/phpBB/install/index.php @@ -69,6 +69,8 @@ else } @ini_set('memory_limit', $mem_limit); +require($phpbb_root_path . 'vendor/.composer/autoload.php'); + // Include essential scripts require($phpbb_root_path . 'includes/class_loader.' . $phpEx); require($phpbb_root_path . 'includes/functions.' . $phpEx); diff --git a/tests/bootstrap.php b/tests/bootstrap.php index bf946df381..63e6f4b280 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -29,6 +29,8 @@ else define('STRIP', (get_magic_quotes_gpc()) ? true : false); } +require_once $phpbb_root_path . 'vendor/.composer/autoload.php'; + require_once $phpbb_root_path . 'includes/constants.php'; require_once $phpbb_root_path . 'includes/class_loader.' . $phpEx; From 0af7d610c08307fbe8df20e0d44e54dcb9429d64 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Sat, 17 Mar 2012 22:45:27 -0400 Subject: [PATCH 11/29] [feature/event-dispatcher] Delete hard dependency on composer. Applications should not depend on package managers. PHPBB3-9550 --- phpBB/common.php | 2 -- phpBB/download/file.php | 2 -- phpBB/install/database_update.php | 2 -- phpBB/install/index.php | 2 -- tests/bootstrap.php | 2 -- 5 files changed, 10 deletions(-) diff --git a/phpBB/common.php b/phpBB/common.php index c48418276a..132b95c1fe 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -72,8 +72,6 @@ if (!empty($load_extensions) && function_exists('dl')) } } -require($phpbb_root_path . 'vendor/.composer/autoload.php'); - // Include files require($phpbb_root_path . 'includes/class_loader.' . $phpEx); require($phpbb_root_path . 'includes/session.' . $phpEx); diff --git a/phpBB/download/file.php b/phpBB/download/file.php index 3f14a9cb82..2baa9d6c8a 100644 --- a/phpBB/download/file.php +++ b/phpBB/download/file.php @@ -38,8 +38,6 @@ if (isset($_GET['avatar'])) exit; } - require($phpbb_root_path . 'vendor/.composer/autoload.php'); - require($phpbb_root_path . 'includes/class_loader.' . $phpEx); require($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx); require($phpbb_root_path . 'includes/constants.' . $phpEx); diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index a1c8fe1ef9..843e8c2f23 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -82,8 +82,6 @@ if (!empty($load_extensions) && function_exists('dl')) } } -require($phpbb_root_path . 'vendor/.composer/autoload.php'); - // Include files require($phpbb_root_path . 'includes/class_loader.' . $phpEx); require($phpbb_root_path . 'includes/session.' . $phpEx); diff --git a/phpBB/install/index.php b/phpBB/install/index.php index 7e150c2519..9d003ba6ab 100644 --- a/phpBB/install/index.php +++ b/phpBB/install/index.php @@ -69,8 +69,6 @@ else } @ini_set('memory_limit', $mem_limit); -require($phpbb_root_path . 'vendor/.composer/autoload.php'); - // Include essential scripts require($phpbb_root_path . 'includes/class_loader.' . $phpEx); require($phpbb_root_path . 'includes/functions.' . $phpEx); diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 3544c66c3d..302701e3b3 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -12,8 +12,6 @@ $phpbb_root_path = 'phpBB/'; $phpEx = 'php'; require_once $phpbb_root_path . 'includes/startup.php'; -require_once $phpbb_root_path . 'vendor/.composer/autoload.php'; - $table_prefix = 'phpbb_'; require_once $phpbb_root_path . 'includes/constants.php'; require_once $phpbb_root_path . 'includes/class_loader.' . $phpEx; From fbf34f16ab5526669dae5b7eb130aac0803e3aed Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Sun, 18 Mar 2012 00:48:30 -0400 Subject: [PATCH 12/29] [feature/event-dispatcher] Implement configurable autoloader selection. The code is in startup.php which should be used by all scripts. PHPBB3-9550 --- phpBB/includes/startup.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/phpBB/includes/startup.php b/phpBB/includes/startup.php index 2100fbd97e..de55db2960 100644 --- a/phpBB/includes/startup.php +++ b/phpBB/includes/startup.php @@ -146,5 +146,26 @@ if (function_exists('date_default_timezone_set') && function_exists('date_defaul date_default_timezone_set(@date_default_timezone_get()); } +// Autoloading of dependencies. +// Three options are supported: +// 1. Specify PHPBB_AUTOLOAD=/path/to/autoload.php in the environment. +// This is useful for running CLI scripts and tests. +// /path/to/autoload.php should define and register class loaders +// for all of phpBB's dependencies. +// 2. If dependencies are installed with Composer, Composer will create a +// vendor/.composer/autoload.php. If this file exists it will be +// automatically used by phpBB. +// 3. Failing that phpBB assumes that autoloading has been set up in +// some other way. This might be useful in cases when phpBB is integrated +// into a larger program. +if (getenv('PHPBB_AUTOLOAD')) +{ + require(getenv('PHPBB_AUTOLOAD')); +} +else if (file_exists($phpbb_root_path . 'vendor/.composer/autoload.php')) +{ + require($phpbb_root_path . 'vendor/.composer/autoload.php'); +} + $starttime = explode(' ', microtime()); $starttime = $starttime[1] + $starttime[0]; From be23445b8c40b99c0d27bfb99521022d7b4705e8 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Fri, 3 Feb 2012 02:17:49 -0500 Subject: [PATCH 13/29] [feature/event-dispatcher] Add get_data_filtered function to event data. Its purpose is to discard any keys added by hooks to data stored in the event, such that only keys that the ledge knows how to handle are processed. PHPBB3-9550 --- phpBB/includes/event/data.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/phpBB/includes/event/data.php b/phpBB/includes/event/data.php index 62e2f2312e..5780ddbfff 100644 --- a/phpBB/includes/event/data.php +++ b/phpBB/includes/event/data.php @@ -36,6 +36,16 @@ class phpbb_event_data extends Event implements ArrayAccess return $this->data; } + /* + * Returns data filtered to only include specified keys. + * + * This effectively discards any keys added to data by hooks. + */ + public function get_data_filtered($keys) + { + return array_intersect_key($this->data, array_flip($keys)); + } + public function offsetExists($offset) { return isset($this->data[$offset]); From 43899ffdf3e36cf2d107bf5a09c5f37faffdf3c2 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Fri, 3 Feb 2012 02:25:32 -0500 Subject: [PATCH 14/29] [feature/event-dispatcher] Implement mutation for page_header ledge. PHPBB3-9550 --- phpBB/includes/functions.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 024fa612f0..bd7ed71dcb 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4762,9 +4762,10 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 'A_COOKIE_SETTINGS' => addslashes('; path=' . $config['cookie_path'] . ((!$config['cookie_domain'] || $config['cookie_domain'] == 'localhost' || $config['cookie_domain'] == '127.0.0.1') ? '' : '; domain=' . $config['cookie_domain']) . ((!$config['cookie_secure']) ? '' : '; secure')), )); - $event = new phpbb_event_data(); - $event->set_data(compact('page_title', 'display_online_list', 'item_id', 'item')); + $vars = array('page_title', 'display_online_list', 'item_id', 'item'); + $event = new phpbb_event_data(compact($vars)); $phpbb_dispatcher->dispatch('core.page_header', $event); + extract($event->get_data_filtered($vars)); // application/xhtml+xml not used because of IE header('Content-type: text/html; charset=UTF-8'); From 847d47a533a1288aa0fcc701ce86abf970184608 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sun, 18 Mar 2012 23:12:17 +0100 Subject: [PATCH 15/29] [feature/event-dispatcher] Change subscriber naming {subscriber => listener}.php This is more consistent with what Symfony2 uses (EventListener/FooListener.php). PHPBB3-9550 --- phpBB/includes/event/extension_subscriber_loader.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/event/extension_subscriber_loader.php b/phpBB/includes/event/extension_subscriber_loader.php index aa32ca9686..60e7fe2382 100644 --- a/phpBB/includes/event/extension_subscriber_loader.php +++ b/phpBB/includes/event/extension_subscriber_loader.php @@ -33,7 +33,7 @@ class phpbb_event_extension_subscriber_loader $finder = $this->extension_manager->get_finder(); $subscriber_classes = $finder ->extension_directory('/event') - ->suffix('subscriber') + ->suffix('listener') ->core_path('event/') ->get_classes(); From b4b586ae10ce34d1c7d00d784fac7a51804eff3e Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Wed, 21 Mar 2012 13:09:39 +0100 Subject: [PATCH 16/29] [feature/event-dispatcher] Switch subscriber loader to EventDispatcherInterface Do not hardcode the implementation of EventDispatcher. PHPBB3-9550 --- phpBB/includes/event/extension_subscriber_loader.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/event/extension_subscriber_loader.php b/phpBB/includes/event/extension_subscriber_loader.php index 60e7fe2382..155846d53d 100644 --- a/phpBB/includes/event/extension_subscriber_loader.php +++ b/phpBB/includes/event/extension_subscriber_loader.php @@ -15,14 +15,14 @@ if (!defined('IN_PHPBB')) exit; } -use Symfony\Component\EventDispatcher\EventDispatcher; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; class phpbb_event_extension_subscriber_loader { private $dispatcher; private $extension_manager; - public function __construct(EventDispatcher $dispatcher, phpbb_extension_manager $extension_manager) + public function __construct(EventDispatcherInterface $dispatcher, phpbb_extension_manager $extension_manager) { $this->dispatcher = $dispatcher; $this->extension_manager = $extension_manager; From baefbdb8825a37051a200203a0191d34caa12229 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Wed, 21 Mar 2012 13:15:45 +0100 Subject: [PATCH 17/29] [feature/event-dispatcher] Add phpbb_event_dispatcher_wrapper PHPBB3-9550 --- phpBB/common.php | 2 +- phpBB/includes/event/dispatcher_wrapper.php | 88 +++++++++++++++++++++ 2 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 phpBB/includes/event/dispatcher_wrapper.php diff --git a/phpBB/common.php b/phpBB/common.php index 132b95c1fe..c7e66ef0d6 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -100,7 +100,7 @@ $phpbb_class_loader_ext->set_cache($cache->get_driver()); $phpbb_class_loader->set_cache($cache->get_driver()); // Instantiate some basic classes -$phpbb_dispatcher = new EventDispatcher(); +$phpbb_dispatcher = new phpbb_event_dispatcher_wrapper(new EventDispatcher()); $request = new phpbb_request(); $user = new user(); $auth = new auth(); diff --git a/phpBB/includes/event/dispatcher_wrapper.php b/phpBB/includes/event/dispatcher_wrapper.php new file mode 100644 index 0000000000..5f5d653c3c --- /dev/null +++ b/phpBB/includes/event/dispatcher_wrapper.php @@ -0,0 +1,88 @@ +trigger_event('core.index', compact($vars))); +* +* Apart from that it implements the EventDispatcherInterface +* and proxies all method calls to the member dispatcher. +*/ +class phpbb_event_dispatcher_wrapper implements EventDispatcherInterface +{ + private $dispatcher; + + public function __construct(EventDispatcherInterface $dispatcher) + { + $this->dispatcher = $dispatcher; + } + + public function dispatch($eventName, Event $event = null) + { + $this->dispatcher->dispatch($eventName, $event); + } + + public function addListener($eventName, $listener, $priority = 0) + { + $this->dispatcher->addListener($eventName, $listener, $priority); + } + + public function addSubscriber(EventSubscriberInterface $subscriber) + { + $this->dispatcher->addSubscriber($subscriber); + } + + public function removeListener($eventName, $listener) + { + $this->dispatcher->removeListener($eventName, $listener); + } + + public function removeSubscriber(EventSubscriberInterface $subscriber) + { + $this->dispatcher->removeSubscriber($subscriber); + } + + public function getListeners($eventName = null) + { + return $this->dispatcher->getListeners($eventName); + } + + public function hasListeners($eventName = null) + { + return $this->dispatcher->hasListeners($eventName); + } + + public function trigger_event($eventName, $data = array()) + { + $event = new phpbb_event_data($data); + $this->dispatch($eventName, $event); + return $event->get_data_filtered(array_keys($data)); + } +} From afc2c5a2e3c56e4e6f96f9ce122a2695a0008f15 Mon Sep 17 00:00:00 2001 From: Michael Cullum Date: Sat, 24 Mar 2012 11:03:54 +0000 Subject: [PATCH 18/29] [feature/event-dispatcher] Add composer install to travis PHPBB3-9550 --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index d5e1231584..f21928dd37 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,6 +13,8 @@ before_script: - sh -c "if [ '$DB' = 'mysql' ]; then mysql -e 'create database IF NOT EXISTS phpbb_tests;'; fi" - sh -c "if [ '$TRAVIS_PHP_VERSION' = '5.2' ]; then pear install --force phpunit/DbUnit; else pyrus install --force phpunit/DbUnit; fi" - phpenv rehash + - curl -s http://getcomposer.org/installer | php + - php composer.phar install script: - phpunit --configuration travis/phpunit-$DB-travis.xml From 400277c03624788e6a31f9aa4a15b883478f58cc Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 24 Mar 2012 15:45:18 +0100 Subject: [PATCH 19/29] [feature/event-dispatcher] Change phpbb_event_dispatcher to inheritance, tests PHPBB3-9550 --- phpBB/common.php | 2 +- phpBB/includes/event/dispatcher.php | 42 ++++++++++ phpBB/includes/event/dispatcher_wrapper.php | 88 --------------------- tests/event/dispatcher_test.php | 29 +++++++ 4 files changed, 72 insertions(+), 89 deletions(-) create mode 100644 phpBB/includes/event/dispatcher.php delete mode 100644 phpBB/includes/event/dispatcher_wrapper.php create mode 100644 tests/event/dispatcher_test.php diff --git a/phpBB/common.php b/phpBB/common.php index c7e66ef0d6..fafcb81feb 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -100,7 +100,7 @@ $phpbb_class_loader_ext->set_cache($cache->get_driver()); $phpbb_class_loader->set_cache($cache->get_driver()); // Instantiate some basic classes -$phpbb_dispatcher = new phpbb_event_dispatcher_wrapper(new EventDispatcher()); +$phpbb_dispatcher = new phpbb_event_dispatcher(); $request = new phpbb_request(); $user = new user(); $auth = new auth(); diff --git a/phpBB/includes/event/dispatcher.php b/phpBB/includes/event/dispatcher.php new file mode 100644 index 0000000000..2bf46b9b06 --- /dev/null +++ b/phpBB/includes/event/dispatcher.php @@ -0,0 +1,42 @@ +trigger_event('core.index', compact($vars))); +* +*/ +class phpbb_event_dispatcher extends EventDispatcher +{ + public function trigger_event($eventName, $data = array()) + { + $event = new phpbb_event_data($data); + $this->dispatch($eventName, $event); + return $event->get_data_filtered(array_keys($data)); + } +} diff --git a/phpBB/includes/event/dispatcher_wrapper.php b/phpBB/includes/event/dispatcher_wrapper.php deleted file mode 100644 index 5f5d653c3c..0000000000 --- a/phpBB/includes/event/dispatcher_wrapper.php +++ /dev/null @@ -1,88 +0,0 @@ -trigger_event('core.index', compact($vars))); -* -* Apart from that it implements the EventDispatcherInterface -* and proxies all method calls to the member dispatcher. -*/ -class phpbb_event_dispatcher_wrapper implements EventDispatcherInterface -{ - private $dispatcher; - - public function __construct(EventDispatcherInterface $dispatcher) - { - $this->dispatcher = $dispatcher; - } - - public function dispatch($eventName, Event $event = null) - { - $this->dispatcher->dispatch($eventName, $event); - } - - public function addListener($eventName, $listener, $priority = 0) - { - $this->dispatcher->addListener($eventName, $listener, $priority); - } - - public function addSubscriber(EventSubscriberInterface $subscriber) - { - $this->dispatcher->addSubscriber($subscriber); - } - - public function removeListener($eventName, $listener) - { - $this->dispatcher->removeListener($eventName, $listener); - } - - public function removeSubscriber(EventSubscriberInterface $subscriber) - { - $this->dispatcher->removeSubscriber($subscriber); - } - - public function getListeners($eventName = null) - { - return $this->dispatcher->getListeners($eventName); - } - - public function hasListeners($eventName = null) - { - return $this->dispatcher->hasListeners($eventName); - } - - public function trigger_event($eventName, $data = array()) - { - $event = new phpbb_event_data($data); - $this->dispatch($eventName, $event); - return $event->get_data_filtered(array_keys($data)); - } -} diff --git a/tests/event/dispatcher_test.php b/tests/event/dispatcher_test.php new file mode 100644 index 0000000000..59e51b1cdc --- /dev/null +++ b/tests/event/dispatcher_test.php @@ -0,0 +1,29 @@ +addListener('core.test_event', function (phpbb_event_data $event) { + $event['foo'] = $event['foo'] . '2'; + $event['bar'] = $event['bar'] . '2'; + }); + + $foo = 'foo'; + $bar = 'bar'; + + $vars = array('foo', 'bar'); + $result = $dispatcher->trigger_event('core.test_event', compact($vars)); + + $this->assertSame(array('foo' => 'foo2', 'bar' => 'bar2'), $result); + } +} From a44423baee5d0d5e0fd8899204a71e4a292dc6bf Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 24 Mar 2012 21:37:45 +0100 Subject: [PATCH 20/29] [feature/event-dispatcher] Change composer autoloading options Check if composer's generated autoloader is present, and if not give an error. PHPBB3-9550 --- phpBB/includes/startup.php | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/phpBB/includes/startup.php b/phpBB/includes/startup.php index 9c4e1374ba..45eaff6fc7 100644 --- a/phpBB/includes/startup.php +++ b/phpBB/includes/startup.php @@ -149,22 +149,32 @@ if (function_exists('date_default_timezone_set') && function_exists('date_defaul // Autoloading of dependencies. // Three options are supported: -// 1. Specify PHPBB_AUTOLOAD=/path/to/autoload.php in the environment. -// This is useful for running CLI scripts and tests. +// 1. If dependencies are installed with Composer, Composer will create a +// vendor/.composer/autoload.php. If this file exists it will be +// automatically used by phpBB. This is the default mode that phpBB +// will use when shipped. +// 2. To disable composer autoloading, PHPBB_NO_AUTOLOAD can be specified. +// Additionally specify PHPBB_AUTOLOAD=/path/to/autoload.php in the +// environment. This is useful for running CLI scripts and tests. // /path/to/autoload.php should define and register class loaders // for all of phpBB's dependencies. -// 2. If dependencies are installed with Composer, Composer will create a -// vendor/.composer/autoload.php. If this file exists it will be -// automatically used by phpBB. -// 3. Failing that phpBB assumes that autoloading has been set up in -// some other way. This might be useful in cases when phpBB is integrated -// into a larger program. -if (getenv('PHPBB_AUTOLOAD')) +// 3. You can also set PHPBB_NO_AUTOLOAD without setting PHPBB_AUTOLOAD. +// In this case autoloading needs to be defined before running any phpBB +// script. This might be useful in cases when phpBB is integrated into a +// larger program. +if (getenv('PHPBB_NO_AUTOLOAD')) { - require(getenv('PHPBB_AUTOLOAD')); + if (getenv('PHPBB_AUTOLOAD')) + { + require(getenv('PHPBB_AUTOLOAD')); + } } -else if (file_exists($phpbb_root_path . 'vendor/.composer/autoload.php')) +else { + if (!file_exists($phpbb_root_path . 'vendor/.composer/autoload.php')) + { + trigger_error('You have not set up composer dependencies. See http://getcomposer.org/.', E_USER_ERROR); + } require($phpbb_root_path . 'vendor/.composer/autoload.php'); } From 821948b96f85d7fb17e853a1fae57073a0a19352 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Wed, 28 Mar 2012 21:45:21 +0200 Subject: [PATCH 21/29] [feature/event-dispatcher] Add missing dispatcher to file.php PHPBB3-9550 --- phpBB/download/file.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/phpBB/download/file.php b/phpBB/download/file.php index 2baa9d6c8a..c01b0789de 100644 --- a/phpBB/download/file.php +++ b/phpBB/download/file.php @@ -56,6 +56,7 @@ if (isset($_GET['avatar'])) $phpbb_class_loader_ext->set_cache($cache->get_driver()); $phpbb_class_loader->set_cache($cache->get_driver()); + $phpbb_dispatcher = new phpbb_event_dispatcher(); $request = new phpbb_request(); $db = new $sql_db(); @@ -78,6 +79,9 @@ if (isset($_GET['avatar'])) // load extensions $phpbb_extension_manager = new phpbb_extension_manager($db, EXT_TABLE, $phpbb_root_path, ".$phpEx", $cache->get_driver()); + $phpbb_subscriber_loader = new phpbb_event_extension_subscriber_loader($phpbb_dispatcher, $phpbb_extension_manager); + $phpbb_subscriber_loader->load(); + $filename = request_var('avatar', ''); $avatar_group = false; $exit = false; From 7f1abaa318cb7008c9eab259003d67790e346094 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Wed, 28 Mar 2012 21:45:56 +0200 Subject: [PATCH 22/29] [feature/event-dispatcher] Add empty dispatcher to installer and db updater PHPBB3-9550 --- phpBB/install/database_update.php | 1 + phpBB/install/index.php | 1 + 2 files changed, 2 insertions(+) diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 843e8c2f23..c2b36f5992 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -120,6 +120,7 @@ $cache = $cache_factory->get_service(); $phpbb_class_loader_ext->set_cache($cache->get_driver()); $phpbb_class_loader->set_cache($cache->get_driver()); +$phpbb_dispatcher = new phpbb_event_dispatcher(); $request = new phpbb_request(); $user = new user(); $db = new $sql_db(); diff --git a/phpBB/install/index.php b/phpBB/install/index.php index 9d003ba6ab..8191288f9d 100644 --- a/phpBB/install/index.php +++ b/phpBB/install/index.php @@ -92,6 +92,7 @@ $cache = $cache_factory->get_service(); $phpbb_class_loader_ext->set_cache($cache->get_driver()); $phpbb_class_loader->set_cache($cache->get_driver()); +$phpbb_dispatcher = new phpbb_event_dispatcher(); $request = new phpbb_request(); // make sure request_var uses this request instance From 138e7dae0087e683fcb170df1e806b8e4f4b86cd Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Wed, 28 Mar 2012 21:48:46 +0200 Subject: [PATCH 23/29] [feature/event-dispatcher] Rename PHPBB_NO_AUTOLOAD=>PHPBB_NO_COMPOSER_AUTOLOAD PHPBB3-9550 --- phpBB/includes/startup.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/phpBB/includes/startup.php b/phpBB/includes/startup.php index 45eaff6fc7..f75d70e366 100644 --- a/phpBB/includes/startup.php +++ b/phpBB/includes/startup.php @@ -153,16 +153,16 @@ if (function_exists('date_default_timezone_set') && function_exists('date_defaul // vendor/.composer/autoload.php. If this file exists it will be // automatically used by phpBB. This is the default mode that phpBB // will use when shipped. -// 2. To disable composer autoloading, PHPBB_NO_AUTOLOAD can be specified. +// 2. To disable composer autoloading, PHPBB_NO_COMPOSER_AUTOLOAD can be specified. // Additionally specify PHPBB_AUTOLOAD=/path/to/autoload.php in the // environment. This is useful for running CLI scripts and tests. // /path/to/autoload.php should define and register class loaders // for all of phpBB's dependencies. -// 3. You can also set PHPBB_NO_AUTOLOAD without setting PHPBB_AUTOLOAD. +// 3. You can also set PHPBB_NO_COMPOSER_AUTOLOAD without setting PHPBB_AUTOLOAD. // In this case autoloading needs to be defined before running any phpBB // script. This might be useful in cases when phpBB is integrated into a // larger program. -if (getenv('PHPBB_NO_AUTOLOAD')) +if (getenv('PHPBB_NO_COMPOSER_AUTOLOAD')) { if (getenv('PHPBB_AUTOLOAD')) { From 28b67d24e4164d4da511af42f26170ddc7376c90 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Thu, 29 Mar 2012 08:43:42 +0200 Subject: [PATCH 24/29] [feature/event-dispatcher] Fix docblock in phpbb_event_data PHPBB3-10732 --- phpBB/includes/event/data.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/phpBB/includes/event/data.php b/phpBB/includes/event/data.php index 5780ddbfff..47cb2d5a30 100644 --- a/phpBB/includes/event/data.php +++ b/phpBB/includes/event/data.php @@ -36,11 +36,11 @@ class phpbb_event_data extends Event implements ArrayAccess return $this->data; } - /* - * Returns data filtered to only include specified keys. - * - * This effectively discards any keys added to data by hooks. - */ + /** + * Returns data filtered to only include specified keys. + * + * This effectively discards any keys added to data by hooks. + */ public function get_data_filtered($keys) { return array_intersect_key($this->data, array_flip($keys)); From 7aef3eb7b3dae478fe90c5dfdb276b693c726272 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Thu, 29 Mar 2012 21:29:56 +0200 Subject: [PATCH 25/29] [feature/event-dispatcher] Braces CS fix PHPBB3-9550 --- phpBB/includes/event/extension_subscriber_loader.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/event/extension_subscriber_loader.php b/phpBB/includes/event/extension_subscriber_loader.php index 155846d53d..71b16b8371 100644 --- a/phpBB/includes/event/extension_subscriber_loader.php +++ b/phpBB/includes/event/extension_subscriber_loader.php @@ -37,7 +37,8 @@ class phpbb_event_extension_subscriber_loader ->core_path('event/') ->get_classes(); - foreach ($subscriber_classes as $class) { + foreach ($subscriber_classes as $class) + { $subscriber = new $class(); $this->dispatcher->addSubscriber($subscriber); } From b250ffc561a631d6639c80017e7d0178e7c68e05 Mon Sep 17 00:00:00 2001 From: Michael Cullum Date: Thu, 29 Mar 2012 23:19:35 +0100 Subject: [PATCH 26/29] [feature/event-dispatcher] Add .gitignore to ignore the composer.phar file PHPBB3-9550 --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index eb7b546445..c6db64b115 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ /phpBB/cache/*.html /phpBB/cache/*.php /phpBB/cache/queue.php.lock +/phpBB/composer.phar /phpBB/config.php /phpBB/ext/* /phpBB/files/* From 0d6a5cb6ae29348a247c8f42e2046c8b84741aa5 Mon Sep 17 00:00:00 2001 From: Michael Cullum Date: Fri, 30 Mar 2012 11:02:48 +0100 Subject: [PATCH 27/29] [feature/event-dispatcher] Update core.page_header event Update it to the new correct format. PHPBB3-9550 --- phpBB/includes/functions.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index bd7ed71dcb..7a96dd3609 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4763,9 +4763,7 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 )); $vars = array('page_title', 'display_online_list', 'item_id', 'item'); - $event = new phpbb_event_data(compact($vars)); - $phpbb_dispatcher->dispatch('core.page_header', $event); - extract($event->get_data_filtered($vars)); + extract($phpbb_dispatcher->trigger_event('core.page_header', compact($vars))); // application/xhtml+xml not used because of IE header('Content-type: text/html; charset=UTF-8'); From cab437ae83297a8fc092fe77fdae8eb66d3b93a1 Mon Sep 17 00:00:00 2001 From: Michael Cullum Date: Fri, 30 Mar 2012 12:59:37 +0100 Subject: [PATCH 28/29] [feature/event-dispatcher] Add dependencies install information PHPBB3-9550 --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index 51e65176c6..a7feb8db40 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,15 @@ phpBB is a free bulletin board written in PHP. Find support and lots more on [phpBB.com](http://www.phpbb.com)! Discuss the development on [area51](http://area51.phpbb.com/phpBB/index.php). +## INSTALLING DEPENDENCIES + +To be able to run an installation from the repo (and not from a pre-built package) you need to run the following commands to install phpBB's dependencies. + + cd phpBB + curl -s http://getcomposer.org/installer | php + php composer.phar install + + ## CONTRIBUTE 1. [Create an account on phpBB.com](http://www.phpbb.com/community/ucp.php?mode=register) From 951e2c8d0c32e6c2bcae02e2f2ff8be35af35b36 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Fri, 30 Mar 2012 14:22:20 +0200 Subject: [PATCH 29/29] [feature/event-dispatcher] Fix copyright years PHPBB3-9550 --- phpBB/includes/event/data.php | 2 +- phpBB/includes/event/extension_subscriber_loader.php | 2 +- tests/event/dispatcher_test.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/phpBB/includes/event/data.php b/phpBB/includes/event/data.php index 47cb2d5a30..70718ff0ae 100644 --- a/phpBB/includes/event/data.php +++ b/phpBB/includes/event/data.php @@ -2,7 +2,7 @@ /** * * @package phpBB3 -* @copyright (c) 2011 phpBB Group +* @copyright (c) 2012 phpBB Group * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ diff --git a/phpBB/includes/event/extension_subscriber_loader.php b/phpBB/includes/event/extension_subscriber_loader.php index 71b16b8371..d933b943d7 100644 --- a/phpBB/includes/event/extension_subscriber_loader.php +++ b/phpBB/includes/event/extension_subscriber_loader.php @@ -2,7 +2,7 @@ /** * * @package phpBB3 -* @copyright (c) 2011 phpBB Group +* @copyright (c) 2012 phpBB Group * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ diff --git a/tests/event/dispatcher_test.php b/tests/event/dispatcher_test.php index 59e51b1cdc..f8fe060d99 100644 --- a/tests/event/dispatcher_test.php +++ b/tests/event/dispatcher_test.php @@ -2,7 +2,7 @@ /** * * @package testing -* @copyright (c) 2010 phpBB Group +* @copyright (c) 2012 phpBB Group * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */