_subscribers = $subscribers; } /** * Notify registered subscribers, which are interested in event * * @param string $eventName * @param array $parameters Parameters to be passed to each subscriber * @param bool $reverseOrder Whether subscribers should be notified in reverse order */ public function fireEvent($eventName, array $parameters = [], $reverseOrder = false) { $subscribers = $reverseOrder ? array_reverse($this->_subscribers) : $this->_subscribers; foreach ($subscribers as $subscriberInstance) { $callback = [$subscriberInstance, $eventName]; if (is_callable($callback)) { call_user_func_array($callback, $parameters); } } } }