4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\EventDispatcher\Debug;
14 use Symfony\Component\Stopwatch\Stopwatch;
15 use Symfony\Component\EventDispatcher\Event;
16 use Symfony\Component\EventDispatcher\EventDispatcherInterface;
19 * @author Fabien Potencier <fabien@symfony.com>
26 private $stoppedPropagation;
30 public function __construct($listener, $name, Stopwatch $stopwatch, EventDispatcherInterface $dispatcher = null)
32 $this->listener = $listener;
34 $this->stopwatch = $stopwatch;
35 $this->dispatcher = $dispatcher;
36 $this->called = false;
37 $this->stoppedPropagation = false;
40 public function getWrappedListener()
42 return $this->listener;
45 public function wasCalled()
50 public function stoppedPropagation()
52 return $this->stoppedPropagation;
55 public function __invoke(Event $event, $eventName, EventDispatcherInterface $dispatcher)
59 $e = $this->stopwatch->start($this->name, 'event_listener');
61 call_user_func($this->listener, $event, $eventName, $this->dispatcher ?: $dispatcher);
63 if ($e->isStarted()) {
67 if ($event->isPropagationStopped()) {
68 $this->stoppedPropagation = true;