/** * Fires the specified event. The listeners will called by the given priority at Observer annotation. * * @param string $event name of event * @param array $parameters event parameters */ public function raise($event) { $parameters = []; // called like this: raise('event', param, param1, param2, ...) if (func_num_args() > 1) { $event = func_get_arg(0); $tmpParameters = func_get_args(); $parameters = array_splice($tmpParameters, 1); } if (isset($this->events[$event])) { $listeners = $this->events[$event]; foreach ($listeners as $listener) { if ($listener['static']) { Components::callStaticMethod($listener['component'], $listener['method'], $parameters); } else { self::callNonStaticListener($listener, $parameters); } } } }