Skip to content

Commit bb33ce0

Browse files
feature #41358 [EventDispatcher] Removed deprecated code (malteschlueter)
This PR was merged into the 6.0 branch. Discussion ---------- [EventDispatcher] Removed deprecated code | Q | A | ------------- | --- | Branch? | 6.0 | Bug fix? | no | New feature? | no | Deprecations? | yes | Tickets | - | License | MIT | Doc PR | - This remove deprecated code from EventDispatcher. The `LegacyEventDispatcherProxy` is removed in #41304. Is it necessary to update the Changelog or Upgrade.md that the classes are not configurable any more? Commits ------- 70b8b16 [EventDispatcher] Removed deprecated code
2 parents 3792264 + 70b8b16 commit bb33ce0

File tree

2 files changed

+11
-34
lines changed

2 files changed

+11
-34
lines changed

src/Symfony/Component/EventDispatcher/DependencyInjection/AddEventAliasesPass.php

+3-9
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,18 @@
2222
class AddEventAliasesPass implements CompilerPassInterface
2323
{
2424
private $eventAliases;
25-
private $eventAliasesParameter;
2625

27-
public function __construct(array $eventAliases, string $eventAliasesParameter = 'event_dispatcher.event_aliases')
26+
public function __construct(array $eventAliases)
2827
{
29-
if (1 < \func_num_args()) {
30-
trigger_deprecation('symfony/event-dispatcher', '5.3', 'Configuring "%s" is deprecated.', __CLASS__);
31-
}
32-
3328
$this->eventAliases = $eventAliases;
34-
$this->eventAliasesParameter = $eventAliasesParameter;
3529
}
3630

3731
public function process(ContainerBuilder $container): void
3832
{
39-
$eventAliases = $container->hasParameter($this->eventAliasesParameter) ? $container->getParameter($this->eventAliasesParameter) : [];
33+
$eventAliases = $container->hasParameter('event_dispatcher.event_aliases') ? $container->getParameter('event_dispatcher.event_aliases') : [];
4034

4135
$container->setParameter(
42-
$this->eventAliasesParameter,
36+
'event_dispatcher.event_aliases',
4337
array_merge($eventAliases, $this->eventAliases)
4438
);
4539
}

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

+8-25
Original file line numberDiff line numberDiff line change
@@ -25,28 +25,11 @@
2525
*/
2626
class RegisterListenersPass implements CompilerPassInterface
2727
{
28-
protected $dispatcherService;
29-
protected $listenerTag;
30-
protected $subscriberTag;
31-
protected $eventAliasesParameter;
32-
3328
private $hotPathEvents = [];
3429
private $hotPathTagName;
3530
private $noPreloadEvents = [];
3631
private $noPreloadTagName;
3732

38-
public function __construct(string $dispatcherService = 'event_dispatcher', string $listenerTag = 'kernel.event_listener', string $subscriberTag = 'kernel.event_subscriber', string $eventAliasesParameter = 'event_dispatcher.event_aliases')
39-
{
40-
if (0 < \func_num_args()) {
41-
trigger_deprecation('symfony/event-dispatcher', '5.3', 'Configuring "%s" is deprecated.', __CLASS__);
42-
}
43-
44-
$this->dispatcherService = $dispatcherService;
45-
$this->listenerTag = $listenerTag;
46-
$this->subscriberTag = $subscriberTag;
47-
$this->eventAliasesParameter = $eventAliasesParameter;
48-
}
49-
5033
/**
5134
* @return $this
5235
*/
@@ -71,26 +54,26 @@ public function setNoPreloadEvents(array $noPreloadEvents, string $tagName = 'co
7154

7255
public function process(ContainerBuilder $container)
7356
{
74-
if (!$container->hasDefinition($this->dispatcherService) && !$container->hasAlias($this->dispatcherService)) {
57+
if (!$container->hasDefinition('event_dispatcher') && !$container->hasAlias('event_dispatcher')) {
7558
return;
7659
}
7760

7861
$aliases = [];
7962

80-
if ($container->hasParameter($this->eventAliasesParameter)) {
81-
$aliases = $container->getParameter($this->eventAliasesParameter);
63+
if ($container->hasParameter('event_dispatcher.event_aliases')) {
64+
$aliases = $container->getParameter('event_dispatcher.event_aliases');
8265
}
8366

84-
$globalDispatcherDefinition = $container->findDefinition($this->dispatcherService);
67+
$globalDispatcherDefinition = $container->findDefinition('event_dispatcher');
8568

86-
foreach ($container->findTaggedServiceIds($this->listenerTag, true) as $id => $events) {
69+
foreach ($container->findTaggedServiceIds('kernel.event_listener', true) as $id => $events) {
8770
$noPreload = 0;
8871

8972
foreach ($events as $event) {
9073
$priority = $event['priority'] ?? 0;
9174

9275
if (!isset($event['event'])) {
93-
if ($container->getDefinition($id)->hasTag($this->subscriberTag)) {
76+
if ($container->getDefinition($id)->hasTag('kernel.event_subscriber')) {
9477
continue;
9578
}
9679

@@ -133,7 +116,7 @@ public function process(ContainerBuilder $container)
133116

134117
$extractingDispatcher = new ExtractingEventDispatcher();
135118

136-
foreach ($container->findTaggedServiceIds($this->subscriberTag, true) as $id => $tags) {
119+
foreach ($container->findTaggedServiceIds('kernel.event_subscriber', true) as $id => $tags) {
137120
$def = $container->getDefinition($id);
138121

139122
// We must assume that the class value has been correctly filled, even if the service is created by a factory
@@ -195,7 +178,7 @@ private function getEventFromTypeDeclaration(ContainerBuilder $container, string
195178
|| $type->isBuiltin()
196179
|| Event::class === ($name = $type->getName())
197180
) {
198-
throw new InvalidArgumentException(sprintf('Service "%s" must define the "event" attribute on "%s" tags.', $id, $this->listenerTag));
181+
throw new InvalidArgumentException(sprintf('Service "%s" must define the "event" attribute on "kernel.event_listener" tags.', $id));
199182
}
200183

201184
return $name;

0 commit comments

Comments
 (0)