[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
This commit is contained in:
Oleg Pudeyev 2012-02-03 02:17:49 -05:00
parent fbf34f16ab
commit be23445b8c

View file

@ -36,6 +36,16 @@ class phpbb_event_data extends Event implements ArrayAccess
return $this->data; 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) public function offsetExists($offset)
{ {
return isset($this->data[$offset]); return isset($this->data[$offset]);