mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
[feature/event-dispatcher] Support setting data on an event
PHPBB3-9550
This commit is contained in:
parent
58a99c97ca
commit
03be976137
2 changed files with 58 additions and 1 deletions
56
phpBB/includes/event/data.php
Normal file
56
phpBB/includes/event/data.php
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
<?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;
|
||||||
|
}
|
||||||
|
|
||||||
|
class phpbb_event_data extends phpbb_event implements ArrayAccess
|
||||||
|
{
|
||||||
|
private $data;
|
||||||
|
|
||||||
|
public function __construct(array $data = array())
|
||||||
|
{
|
||||||
|
$this->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]);
|
||||||
|
}
|
||||||
|
}
|
|
@ -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')),
|
'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);
|
$phpbb_dispatcher->dispatch('page_header', $event);
|
||||||
|
|
||||||
// application/xhtml+xml not used because of IE
|
// application/xhtml+xml not used because of IE
|
||||||
|
|
Loading…
Add table
Reference in a new issue