From a7b7f5479eabfe00c462fc7640d712ec99fdda5f Mon Sep 17 00:00:00 2001 From: Tobias Schultze Date: Thu, 17 Sep 2015 03:42:05 +0200 Subject: [PATCH] [EventDispatcher] skip one lazy loading call --- .../ContainerAwareEventDispatcher.php | 19 ++------------ .../EventDispatcher/EventDispatcher.php | 26 +++++++------------ 2 files changed, 11 insertions(+), 34 deletions(-) diff --git a/src/Symfony/Component/EventDispatcher/ContainerAwareEventDispatcher.php b/src/Symfony/Component/EventDispatcher/ContainerAwareEventDispatcher.php index aedad6ef77..8782d8e87b 100644 --- a/src/Symfony/Component/EventDispatcher/ContainerAwareEventDispatcher.php +++ b/src/Symfony/Component/EventDispatcher/ContainerAwareEventDispatcher.php @@ -103,7 +103,7 @@ class ContainerAwareEventDispatcher extends EventDispatcher } /** - * @see EventDispatcherInterface::hasListeners() + * {@inheritdoc} */ public function hasListeners($eventName = null) { @@ -119,7 +119,7 @@ class ContainerAwareEventDispatcher extends EventDispatcher } /** - * @see EventDispatcherInterface::getListeners() + * {@inheritdoc} */ public function getListeners($eventName = null) { @@ -155,21 +155,6 @@ class ContainerAwareEventDispatcher extends EventDispatcher } } - /** - * {@inheritdoc} - * - * Lazily loads listeners for this event from the dependency injection - * container. - * - * @throws \InvalidArgumentException if the service is not defined - */ - public function dispatch($eventName, Event $event = null) - { - $this->lazyLoad($eventName); - - return parent::dispatch($eventName, $event); - } - public function getContainer() { return $this->container; diff --git a/src/Symfony/Component/EventDispatcher/EventDispatcher.php b/src/Symfony/Component/EventDispatcher/EventDispatcher.php index 67097e5662..54a279fb40 100644 --- a/src/Symfony/Component/EventDispatcher/EventDispatcher.php +++ b/src/Symfony/Component/EventDispatcher/EventDispatcher.php @@ -33,9 +33,7 @@ class EventDispatcher implements EventDispatcherInterface private $sorted = array(); /** - * @see EventDispatcherInterface::dispatch() - * - * @api + * {@inheritdoc} */ public function dispatch($eventName, Event $event = null) { @@ -46,17 +44,15 @@ class EventDispatcher implements EventDispatcherInterface $event->setDispatcher($this); $event->setName($eventName); - if (!isset($this->listeners[$eventName])) { - return $event; + if ($listeners = $this->getListeners($eventName)) { + $this->doDispatch($listeners, $eventName, $event); } - $this->doDispatch($this->getListeners($eventName), $eventName, $event); - return $event; } /** - * @see EventDispatcherInterface::getListeners() + * {@inheritdoc} */ public function getListeners($eventName = null) { @@ -82,7 +78,7 @@ class EventDispatcher implements EventDispatcherInterface } /** - * @see EventDispatcherInterface::hasListeners() + * {@inheritdoc} */ public function hasListeners($eventName = null) { @@ -90,9 +86,7 @@ class EventDispatcher implements EventDispatcherInterface } /** - * @see EventDispatcherInterface::addListener() - * - * @api + * {@inheritdoc} */ public function addListener($eventName, $listener, $priority = 0) { @@ -101,7 +95,7 @@ class EventDispatcher implements EventDispatcherInterface } /** - * @see EventDispatcherInterface::removeListener() + * {@inheritdoc} */ public function removeListener($eventName, $listener) { @@ -117,9 +111,7 @@ class EventDispatcher implements EventDispatcherInterface } /** - * @see EventDispatcherInterface::addSubscriber() - * - * @api + * {@inheritdoc} */ public function addSubscriber(EventSubscriberInterface $subscriber) { @@ -137,7 +129,7 @@ class EventDispatcher implements EventDispatcherInterface } /** - * @see EventDispatcherInterface::removeSubscriber() + * {@inheritdoc} */ public function removeSubscriber(EventSubscriberInterface $subscriber) {