Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d8f02e4

Browse filesBrowse files
nicolas-grekaschalasr
authored andcommitted
[EventDispatcher] Fix abstract event subscribers registration
1 parent d16e2a8 commit d8f02e4
Copy full SHA for d8f02e4

File tree

1 file changed

+13
-3
lines changed
Filter options

1 file changed

+13
-3
lines changed

‎src/Symfony/Component/EventDispatcher/DependencyInjection/RegisterListenersPass.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/EventDispatcher/DependencyInjection/RegisterListenersPass.php
+13-3Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
1717
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
1818
use Symfony\Component\EventDispatcher\EventDispatcher;
19+
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
1920

2021
/**
2122
* Compiler pass to register tagged services for an event dispatcher.
@@ -105,8 +106,8 @@ public function process(ContainerBuilder $container)
105106
}
106107
$container->addObjectResource($class);
107108

108-
$r = new \ReflectionClass($class);
109-
$extractingDispatcher->addSubscriber($r->newInstanceWithoutConstructor());
109+
ExtractingEventDispatcher::$subscriber = $class;
110+
$extractingDispatcher->addSubscriber($extractingDispatcher);
110111
foreach ($extractingDispatcher->listeners as $args) {
111112
$args[1] = new ClosureProxyArgument($id, $args[1]);
112113
$definition->addMethodCall('addListener', $args);
@@ -119,12 +120,21 @@ public function process(ContainerBuilder $container)
119120
/**
120121
* @internal
121122
*/
122-
class ExtractingEventDispatcher extends EventDispatcher
123+
class ExtractingEventDispatcher extends EventDispatcher implements EventSubscriberInterface
123124
{
124125
public $listeners = array();
125126

127+
public static $subscriber;
128+
126129
public function addListener($eventName, $listener, $priority = 0)
127130
{
128131
$this->listeners[] = array($eventName, $listener[1], $priority);
129132
}
133+
134+
public static function getSubscribedEvents()
135+
{
136+
$callback = array(self::$subscriber, 'getSubscribedEvents');
137+
138+
return $callback();
139+
}
130140
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.