8000 [FrameworkBundle] dont suggest hidden services in debug:container and debug:autow commands by nicolas-grekas · Pull Request #28690 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[FrameworkBundle] dont suggest hidden services in debug:container and debug:autow commands #28690

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 1 commit into from
Oct 3, 2018
Merged
Show file tree
Hide file tree
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
[FrameworkBundle] dont suggest hidden services in debug:container and…
… debug:autow commands
  • Loading branch information
nicolas-grekas committed Oct 2, 2018
commit 83f5dfb544ceb91758615f5087ea90ca77f0601e
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
} elseif ($tag = $input->getOption('tag')) {
$options = array('tag' => $tag);
} elseif ($name = $input->getArgument('name')) {
$name = $this->findProperServiceName($input, $errorIo, $object, $name);
$name = $this->findProperServiceName($input, $errorIo, $object, $name, $input->getOption('show-hidden'));
$options = array('id' => $name);
} else {
$options = array();
Expand Down Expand Up @@ -208,13 +208,13 @@ protected function getContainerBuilder()
return $this->containerBuilder = $container;
}

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

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

private function findServiceIdsContaining(ContainerBuilder $builder, $name)
private function findServiceIdsContaining(ContainerBuilder $builder, string $name, bool $showHidden)
{
$serviceIds = $builder->getServiceIds();
$foundServiceIds = array();
foreach ($serviceIds as $serviceId) {
if (!$showHidden && 0 === strpos($serviceId, '.')) {
continue;
}
if (false === stripos($serviceId, $name)) {
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ protected function execute(InputInterface $input, OutputInterface $output)

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

if (empty($serviceIds)) {
Expand Down
0