Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[EventDispatcher] Remove ability to configure tags on RegisterListenersPass #41937

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@
class RegisterListenersPass implements CompilerPassInterface
{
private array $hotPathEvents = [];
private string $hotPathTagName = 'container.hot_path';
private array $noPreloadEvents = [];
private string $noPreloadTagName = 'container.no_preload';

/**
* @return $this
Expand All @@ -37,11 +35,6 @@ public function setHotPathEvents(array $hotPathEvents)
{
$this->hotPathEvents = array_flip($hotPathEvents);

if (1 < \func_num_args()) {
trigger_deprecation('symfony/event-dispatcher', '5.4', 'Configuring "$tagName" in "%s" is deprecated.', __METHOD__);
$this->hotPathTagName = func_get_arg(1);
}

return $this;
}

Expand All @@ -52,11 +45,6 @@ public function setNoPreloadEvents(array $noPreloadEvents): self
{
$this->noPreloadEvents = array_flip($noPreloadEvents);

if (1 < \func_num_args()) {
trigger_deprecation('symfony/event-dispatcher', '5.4', 'Configuring "$tagName" in "%s" is deprecated.', __METHOD__);
$this->noPreloadTagName = func_get_arg(1);
}

return $this;
}

Expand Down Expand Up @@ -111,14 +99,14 @@ public function process(ContainerBuilder $container)
$dispatcherDefinition->addMethodCall('addListener', [$event['event'], [new ServiceClosureArgument(new Reference($id)), $event['method']], $priority]);

if (isset($this->hotPathEvents[$event['event']])) {
$container->getDefinition($id)->addTag($this->hotPathTagName);
$container->getDefinition($id)->addTag('container.hot_path');
} elseif (isset($this->noPreloadEvents[$event['event']])) {
++$noPreload;
}
}

if ($noPreload && \count($events) === $noPreload) {
$container->getDefinition($id)->addTag($this->noPreloadTagName);
$container->getDefinition($id)->addTag('container.no_preload');
}
}

Expand Down Expand Up @@ -162,13 +150,13 @@ public function process(ContainerBuilder $container)
}

if (isset($this->hotPathEvents[$args[0]])) {
$container->getDefinition($id)->addTag($this->hotPathTagName);
$container->getDefinition($id)->addTag('container.hot_path');
} elseif (isset($this->noPreloadEvents[$args[0]])) {
++$noPreload;
}
}
if ($noPreload && \count($extractingDispatcher->listeners) === $noPreload) {
$container->getDefinition($id)->addTag($this->noPreloadTagName);
$container->getDefinition($id)->addTag('container.no_preload');
}
$extractingDispatcher->listeners = [];
ExtractingEventDispatcher::$aliases = [];
Expand Down