mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-13 15:34:12 +01:00
Package operations: 2 installs, 23 updates, 0 removals - Updating psr/log (1.1.0 => 1.1.2) - Updating symfony/debug (v3.4.30 => v3.4.35) - Updating symfony/console (v3.4.30 => v3.4.35) - Updating symfony/dotenv (v3.4.30 => v3.4.35) - Updating symfony/routing (v3.4.30 => v3.4.35) - Updating symfony/finder (v3.4.30 => v3.4.35) - Updating symfony/filesystem (v3.4.30 => v3.4.35) - Installing symfony/polyfill-util (v1.12.0) - Installing symfony/polyfill-php56 (v1.12.0) - Updating symfony/http-foundation (v3.4.30 => v3.4.35) - Updating symfony/event-dispatcher (v3.4.30 => v3.4.35) - Updating symfony/http-kernel (v3.4.30 => v3.4.35) - Updating symfony/config (v3.4.30 => v3.4.35) - Updating symfony/dependency-injection (v3.4.30 => v3.4.35) - Updating symfony/class-loader (v3.4.30 => v3.4.35) - Updating symfony/cache (v3.4.30 => v3.4.35) - Updating symfony/framework-bundle (v3.4.30 => v3.4.35) - Updating twig/twig (v1.42.2 => v1.42.4) - Updating symfony/twig-bridge (v3.4.30 => v3.4.35) - Updating symfony/twig-bundle (v3.4.30 => v3.4.35) - Updating symfony/yaml (v3.4.30 => v3.4.35) - Updating symfony/stopwatch (v3.4.30 => v3.4.35) - Updating symfony/var-dumper (v3.4.30 => v3.4.35) - Updating symfony/web-profiler-bundle (v3.4.30 => v3.4.35) - Updating symfony/css-selector (v3.4.30 => v3.4.35)
100 lines
2.8 KiB
PHP
100 lines
2.8 KiB
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of the Symfony package.
|
|
*
|
|
* (c) Fabien Potencier <fabien@symfony.com>
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Symfony\Bundle\FrameworkBundle\Command;
|
|
|
|
use Symfony\Component\Console\Input\InputArgument;
|
|
use Symfony\Component\Console\Input\InputInterface;
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
|
use Symfony\Component\Console\Style\SymfonyStyle;
|
|
|
|
/**
|
|
* A console command for autowiring information.
|
|
*
|
|
* @author Ryan Weaver <ryan@knpuniversity.com>
|
|
*
|
|
* @internal
|
|
*/
|
|
class DebugAutowiringCommand extends ContainerDebugCommand
|
|
{
|
|
protected static $defaultName = 'debug:autowiring';
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
protected function configure()
|
|
{
|
|
$this
|
|
->setDefinition([
|
|
new InputArgument('search', InputArgument::OPTIONAL, 'A search filter'),
|
|
])
|
|
->setDescription('Lists classes/interfaces you can use for autowiring')
|
|
->setHelp(<<<'EOF'
|
|
The <info>%command.name%</info> command displays all classes and interfaces that
|
|
you can use as type-hints for autowiring:
|
|
|
|
<info>php %command.full_name%</info>
|
|
|
|
You can also pass a search term to filter the list:
|
|
|
|
<info>php %command.full_name% log</info>
|
|
|
|
EOF
|
|
)
|
|
;
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
protected function execute(InputInterface $input, OutputInterface $output)
|
|
{
|
|
$io = new SymfonyStyle($input, $output);
|
|
$errorIo = $io->getErrorStyle();
|
|
|
|
$builder = $this->getContainerBuilder();
|
|
$serviceIds = $builder->getServiceIds();
|
|
$serviceIds = array_filter($serviceIds, [$this, 'filterToServiceTypes']);
|
|
|
|
if ($search = $input->getArgument('search')) {
|
|
$serviceIds = array_filter($serviceIds, function ($serviceId) use ($search) {
|
|
return false !== stripos($serviceId, $search);
|
|
});
|
|
|
|
if (empty($serviceIds)) {
|
|
$errorIo->error(sprintf('No autowirable classes or interfaces found matching "%s"', $search));
|
|
|
|
return 1;
|
|
}
|
|
}
|
|
|
|
asort($serviceIds);
|
|
|
|
$io->title('Autowirable Services');
|
|
$io->text('The following classes & interfaces can be used as type-hints when autowiring:');
|
|
if ($search) {
|
|
$io->text(sprintf('(only showing classes/interfaces matching <comment>%s</comment>)', $search));
|
|
}
|
|
$io->newLine();
|
|
$tableRows = [];
|
|
foreach ($serviceIds as $serviceId) {
|
|
$tableRows[] = [sprintf('<fg=cyan>%s</fg=cyan>', $serviceId)];
|
|
if ($builder->hasAlias($serviceId)) {
|
|
$tableRows[] = [sprintf(' alias to %s', $builder->getAlias($serviceId))];
|
|
}
|
|
}
|
|
|
|
$io->table([], $tableRows);
|
|
|
|
return null;
|
|
}
|
|
}
|