-
Improvement
-
Resolution: Fixed
-
Minor
-
3.2.0-dev, 3.2.0-b2
-
None
Currently it is very verbose for an extension to update an $event value, when that value is an array. If you try to update the value directly, you get an ugly error, ie:
$event['foo']['bar'] = 'hello';
|
Indirect modification of overloaded element of phpbb\event\data has no effect
The workaround, is to assign the event to a temporary variable, update the temp variable and reassign it back to the event, i.e.:
$temp = $event['foo']; |
$temp['bar'] = 'hello'; |
$event['foo'] = $temp; |
I think we can add a method to our event/data class that can simplify things, something like:
public function offsetUpdate($offset, $key, $value) |
{
|
$this->data[$offset][$key] = $value; |
}
|
Then an extension can reduce those previous 3 lines of code to 1 line, i.e.:
$event->offsetUpdate('foo', 'bar', 'hello'); |