Page 1 of 1

addEvent for language

Posted: Sun Apr 17, 2016 5:46 pm
by tryteex
Hi.

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');
When I start the admin area, then an exception is thrown

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
I traced the function call
  1. 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);
  2. Function triger in file /system/engine/event.php (line 25) has declaration

    Code: Select all

    public function trigger($trigger, $args = array()) {
    By default, second argument $args is array, but we called function trigger, with string's type.
  3. 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);
  4. Function execute in file /system/engine/action.php (line 23) has declaration

    Code: Select all

    public function execute($registry, array $args = array()) {
    Based from declaration, the second argument must be an 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