addEvent for language
Posted: Sun Apr 17, 2016 5:46 pm
Hi.
I develop my own module. In install function I subscribe to events
When I start the admin area, then an exception is thrown
I traced the function call
I am using php 7.
p.s. Sorry for my English.
p.s.2 The same situation with a subscription to the config
I develop my own module. In install function I subscribe to events
Code: Select all
$this->model_extension_event->addEvent('brainbox', 'admin/language/common/footer/after', 'module/brainbox/add_copyright');
Code: Select all
<b>Fatal error</b>: Uncaught TypeError: Argument 2 passed to Action::execute() must be of the type array, string given, called in .../system/engine/event.php on line 29 and defined in .../system/engine/action.php:23
- In function language in file /system/engine/loader.php called function trigger (line 118, 122), where second argument is $route. It has string type.
Code: Select all
$this->registry->get('event')->trigger('language/' . $route . '/before', $route);
- Function triger in file /system/engine/event.php (line 25) has declaration
By default, second argument $args is array, but we called function trigger, with string's type.
Code: Select all
public function trigger($trigger, $args = array()) {
- Then, we call the execute function (line 29), and the second argument is our parameter of string's type.
Code: Select all
$result = $event->execute($this->registry, $args);
- Function execute in file /system/engine/action.php (line 23) has declaration
Based from declaration, the second argument must be an array.
Code: Select all
public function execute($registry, array $args = array()) {
At this point, an exception is thrown.
I am using php 7.
p.s. Sorry for my English.
p.s.2 The same situation with a subscription to the config