From 03be9761375a082c2a43aceaa1b34661f87d702b Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 7 Jan 2012 21:42:19 +0100 Subject: [PATCH] [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