public function trigger($event, $params = [])
{
if (!isset($this->events[$event])) {
return $this;
}
if (!count($this->events[$event])) {
return $this;
}
$queue = new \SplPriorityQueue();
foreach ($this->events[$event] as $index => $action) {
$queue->insert($index, $action["prio"]);
}
$queue->top();
while ($queue->valid()) {
$index = $queue->current();
if (is_callable($this->events[$event][$index]["fn"])) {
if (call_user_func_array($this->events[$event][$index]["fn"], $params) === false) {
break;
// stop Propagation
}
}
$queue->next();
}
return $this;
}