Skip to content

Commit 83f5dfb

Browse files
[FrameworkBundle] dont suggest hidden services in debug:container and debug:autow commands
1 parent ed6d9b9 commit 83f5dfb

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/Symfony/Bundle/FrameworkBundle/Command/ContainerDebugCommand.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
132132
} elseif ($tag = $input->getOption('tag')) {
133133
$options = array('tag' => $tag);
134134
} elseif ($name = $input->getArgument('name')) {
135-
$name = $this->findProperServiceName($input, $errorIo, $object, $name);
135+
$name = $this->findProperServiceName($input, $errorIo, $object, $name, $input->getOption('show-hidden'));
136136
$options = array('id' => $name);
137137
} else {
138138
$options = array();
@@ -208,13 +208,13 @@ protected function getContainerBuilder()
208208
return $this->containerBuilder = $container;
209209
}
210210

211-
private function findProperServiceName(InputInterface $input, SymfonyStyle $io, ContainerBuilder $builder, $name)
211+
private function findProperServiceName(InputInterface $input, SymfonyStyle $io, ContainerBuilder $builder, string $name, bool $showHidden)
212212
{
213213
if ($builder->has($name) || !$input->isInteractive()) {
214214
return $name;
215215
}
216216

217-
$matchingServices = $this->findServiceIdsContaining($builder, $name);
217+
$matchingServices = $this->findServiceIdsContaining($builder, $name, $showHidden);
218218
if (empty($matchingServices)) {
219219
throw new InvalidArgumentException(sprintf('No services found that match "%s".', $name));
220220
}
@@ -224,11 +224,14 @@ private function findProperServiceName(InputInterface $input, SymfonyStyle $io,
224224
return $io->choice('Select one of the following services to display its information', $matchingServices, $default);
225225
}
226226

227-
private function findServiceIdsContaining(ContainerBuilder $builder, $name)
227+
private function findServiceIdsContaining(ContainerBuilder $builder, string $name, bool $showHidden)
228228
{
229229
$serviceIds = $builder->getServiceIds();
230230
$foundServiceIds = array();
231231
foreach ($serviceIds as $serviceId) {
232+
if (!$showHidden && 0 === strpos($serviceId, '.')) {
233+
continue;
234+
}
232235
if (false === stripos($serviceId, $name)) {
233236
continue;
234237
}

src/Symfony/Bundle/FrameworkBundle/Command/DebugAutowiringCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
6666

6767
if ($search = $input->getArgument('search')) {
6868
$serviceIds = array_filter($serviceIds, function ($serviceId) use ($search) {
69-
return false !== stripos($serviceId, $search);
69+
return false !== stripos($serviceId, $search) && 0 !== strpos($serviceId, '.');
7070
});
7171

7272
if (empty($serviceIds)) {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy