-
-
Notifications
You must be signed in to change notification settings - Fork 687
/
CollectorCompilerPass.php
40 lines (35 loc) · 1.29 KB
/
CollectorCompilerPass.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php declare(strict_types=1);
namespace Rector\DependencyInjection\CompilerPass;
use PhpParser\NodeTraverser;
use PhpParser\NodeVisitor;
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->collectNodeVisitorsToTraverser($containerBuilder);
}
private function collectCommandsToConsoleApplication(ContainerBuilder $containerBuilder): void
{
DefinitionCollector::loadCollectorWithType(
$containerBuilder,
Application::class,
Command::class,
'add'
);
}
private function collectNodeVisitorsToTraverser(ContainerBuilder $containerBuilder): void
{
DefinitionCollector::loadCollectorWithType(
$containerBuilder,
NodeTraverser::class,
NodeVisitor::class,
'addVisitor'
);
}
}