diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/DebugAutowiringCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/DebugAutowiringCommand.php index 97493eb28db24..34fd44cb629c5 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/DebugAutowiringCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/DebugAutowiringCommand.php @@ -12,11 +12,13 @@ namespace Symfony\Bundle\FrameworkBundle\Command; use Symfony\Bundle\FrameworkBundle\Console\Descriptor\Descriptor; +use Symfony\Component\Console\Formatter\OutputFormatterStyle; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; +use Symfony\Component\HttpKernel\Debug\FileLinkFormatter; /** * A console command for autowiring information. @@ -28,6 +30,15 @@ class DebugAutowiringCommand extends ContainerDebugCommand { protected static $defaultName = 'debug:autowiring'; + private $supportsHref; + private $fileLinkFormatter; + + public function __construct(string $name = null, FileLinkFormatter $fileLinkFormatter = null) + { + $this->supportsHref = method_exists(OutputFormatterStyle::class, 'setHref'); + $this->fileLinkFormatter = $fileLinkFormatter; + parent::__construct($name); + } /** * {@inheritdoc} @@ -101,7 +112,12 @@ protected function execute(InputInterface $input, OutputInterface $output) } $previousId = $serviceId.' $'; } + $serviceLine = sprintf('%s', $serviceId); + if ($this->supportsHref && '' !== $fileLink = $this->getFileLink($serviceId)) { + $serviceLine = sprintf('%s', $fileLink, $serviceId); + } + if ($builder->hasAlias($serviceId)) { $hasAlias[$serviceId] = true; $serviceAlias = $builder->getAlias($serviceId); @@ -118,4 +134,14 @@ protected function execute(InputInterface $input, OutputInterface $output) } $io->newLine(); } + + private function getFileLink(string $class): string + { + if (null === $this->fileLinkFormatter + || (null === $r = $this->getContainerBuilder()->getReflectionClass($class, false))) { + return ''; + } + + return (string) $this->fileLinkFormatter->format($r->getFileName(), $r->getStartLine()); + } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/console.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/console.xml index 7b82e9a93e34c..9ce2c77373ed0 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/console.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/console.xml @@ -66,6 +66,8 @@ + null + 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