public function trigger($ev, $data)
{
if (!empty($this->events[$ev])) {
foreach ($this->events[$ev] as $callback) {
$output = $callback($data);
if (!empty($output)) {
return $output;
}
}
}
foreach ($this->listeners as $object) {
$callback = array($object, $ev);
if (is_callable($callback)) {
$output = $object->{$ev}($data);
if (!empty($output)) {
return $output;
}
}
}
throw new \RuntimeException("There was no handler for {$ev}");
}