public function trigger($event)
{
// Get the handlers
$listeners = $this->getListeners($event);
// Set return array
$return = array();
// When there are no handlers
if (empty($listeners)) {
// Skip execution
return $return;
}
// Get the event arguments.
$args = func_get_args();
// Shift the event name off the arguments array
array_shift($args);
// Sort the events.
usort($listeners, [$this, 'listenerSort']);
foreach ($listeners as $listener) {
// Fire the event and fetch the result
$return[] = $listener($event, $args);
// When the bubbling is prevented.
if ($listener->propagationStopped()) {
return $return;
}
}
return $return;
}