Skip to content

Commit

Permalink
[Event] fixed major behavior bug in Dispatcher::triggerEvent()
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-chau committed Feb 3, 2016
1 parent 9d7f587 commit af404d2
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions Event/Dispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@

namespace BackBee\Event;

use Symfony\Component\EventDispatcher\Event as sfEvent;
use Symfony\Component\EventDispatcher\EventDispatcher;
use BackBee\BBApplication;
use BackBee\ClassContent\AbstractClassContent;
use BackBee\Config\Config;
use BackBee\DependencyInjection\Container;
use BackBee\DependencyInjection\Dumper\DumpableServiceInterface;
use BackBee\Event\Exception\ContainerNotFoundException;
use Symfony\Component\EventDispatcher\Event as sfEvent;
use Symfony\Component\EventDispatcher\EventDispatcher;

/**
* An event dispatcher for BB application.
Expand Down Expand Up @@ -152,19 +153,19 @@ public function triggerEvent($eventName, $entity, $eventArgs = null, Event $even
$event = new Event($entity, $eventArgs);
}

if (is_a($entity, 'BackBee\ClassContent\AbstractClassContent')) {
$this->dispatch(strtolower('classcontent.'.$eventName), $event);
$this->dispatch($this->formatEventName($eventName, $entity), $event);

if ($entity instanceof AbstractClassContent) {
foreach (class_parents($entity) as $class) {
if ($class === 'BackBee\ClassContent\AbstractClassContent') {
break;
}

$this->dispatch($this->formatEventName($eventName, $class), $event);
}
}

$this->dispatch($this->formatEventName($eventName, $entity), $event);
$this->dispatch(strtolower('classcontent.'.$eventName), $event);
}
}

/**
Expand Down

0 comments on commit af404d2

Please sign in to comment.