1
0
Fork 0

Throw an exception if no listeners have been found for given event.

pull/2516/head
Max Gfeller 2013-12-19 07:58:58 +01:00
parent 040bbaca51
commit f1c1ba27b4
1 changed files with 4 additions and 0 deletions

View File

@ -118,6 +118,10 @@ class EventDispatcher
{ {
$listeners = $this->getListeners($event); $listeners = $this->getListeners($event);
if(sizeof($listeners) === 0) {
throw new \InvalidArgumentException(sprintf('Script "%s" does not exist', $event->getName()));
}
foreach ($listeners as $callable) { foreach ($listeners as $callable) {
if (!is_string($callable) && is_callable($callable)) { if (!is_string($callable) && is_callable($callable)) {
call_user_func($callable, $event); call_user_func($callable, $event);