rector/src/DependencyInjection/CompilerPass/CollectorCompilerPass.php
TomasVotruba 764ce4bb08 init
2017-07-15 19:01:21 +02:00

41 lines
1.4 KiB
PHP

<?php declare(strict_types=1);
namespace Rector\DependencyInjection\CompilerPass;
use Rector\Contract\Dispatcher\ReconstructorInterface;
use Rector\Dispatcher\NodeDispatcher;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symplify\PackageBuilder\Adapter\Symfony\DependencyInjection\DefinitionCollector;
final class CollectorCompilerPass implements CompilerPassInterface
{
public function process(ContainerBuilder $containerBuilder): void
{
$this->collectCommandsToConsoleApplication($containerBuilder);
$this->collectReconstructorsToNodeDispatcher($containerBuilder);
}
private function collectCommandsToConsoleApplication(ContainerBuilder $containerBuilder): void
{
DefinitionCollector::loadCollectorWithType(
$containerBuilder,
Application::class,
Command::class,
'add'
);
}
private function collectReconstructorsToNodeDispatcher(ContainerBuilder $containerBuilder): void
{
DefinitionCollector::loadCollectorWithType(
$containerBuilder,
NodeDispatcher::class,
ReconstructorInterface::class,
'addReconstructor'
);
}
}