[FrameworkBundle] dont suggest hidden services in debug:container and debug:autow commands
This commit is contained in:
parent
ed6d9b9d7a
commit
83f5dfb544
@ -132,7 +132,7 @@ EOF
|
|||||||
} elseif ($tag = $input->getOption('tag')) {
|
} elseif ($tag = $input->getOption('tag')) {
|
||||||
$options = array('tag' => $tag);
|
$options = array('tag' => $tag);
|
||||||
} elseif ($name = $input->getArgument('name')) {
|
} 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);
|
$options = array('id' => $name);
|
||||||
} else {
|
} else {
|
||||||
$options = array();
|
$options = array();
|
||||||
@ -208,13 +208,13 @@ EOF
|
|||||||
return $this->containerBuilder = $container;
|
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()) {
|
if ($builder->has($name) || !$input->isInteractive()) {
|
||||||
return $name;
|
return $name;
|
||||||
}
|
}
|
||||||
|
|
||||||
$matchingServices = $this->findServiceIdsContaining($builder, $name);
|
$matchingServices = $this->findServiceIdsContaining($builder, $name, $showHidden);
|
||||||
if (empty($matchingServices)) {
|
if (empty($matchingServices)) {
|
||||||
throw new InvalidArgumentException(sprintf('No services found that match "%s".', $name));
|
throw new InvalidArgumentException(sprintf('No services found that match "%s".', $name));
|
||||||
}
|
}
|
||||||
@ -224,11 +224,14 @@ EOF
|
|||||||
return $io->choice('Select one of the following services to display its information', $matchingServices, $default);
|
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();
|
$serviceIds = $builder->getServiceIds();
|
||||||
$foundServiceIds = array();
|
$foundServiceIds = array();
|
||||||
foreach ($serviceIds as $serviceId) {
|
foreach ($serviceIds as $serviceId) {
|
||||||
|
if (!$showHidden && 0 === strpos($serviceId, '.')) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (false === stripos($serviceId, $name)) {
|
if (false === stripos($serviceId, $name)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ EOF
|
|||||||
|
|
||||||
if ($search = $input->getArgument('search')) {
|
if ($search = $input->getArgument('search')) {
|
||||||
$serviceIds = array_filter($serviceIds, function ($serviceId) use ($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)) {
|
if (empty($serviceIds)) {
|
||||||
|
Reference in New Issue
Block a user