|
11 | 11 |
|
12 | 12 | namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler;
|
13 | 13 |
|
14 |
| -@trigger_error(sprintf('%s is deprecated as of 3.2 and will be removed in 4.0. Use Symfony\Component\Console\DependencyInjection\AddConsoleCommandPass instead.', AddConsoleCommandPass::class), E_USER_DEPRECATED); |
| 14 | +@trigger_error(sprintf('%s is deprecated since version 3.2 and will be removed in 4.0. Use Symfony\Component\Console\DependencyInjection\AddConsoleCommandPass instead.', AddConsoleCommandPass::class), E_USER_DEPRECATED); |
15 | 15 |
|
16 |
| -use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; |
17 |
| -use Symfony\Component\DependencyInjection\ContainerBuilder; |
18 |
| -use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; |
| 16 | +use Symfony\Component\Console\DependencyInjection\AddConsoleCommandPass as BaseAddConsoleCommandPass; |
19 | 17 |
|
20 | 18 | /**
|
21 | 19 | * Registers console commands.
|
|
24 | 22 | *
|
25 | 23 | * @deprecated since version 3.2, to be removed in 4.0. Use Symfony\Component\Console\DependencyInjection\AddConsoleCommandPass instead.
|
26 | 24 | */
|
27 |
| -class AddConsoleCommandPass implements CompilerPassInterface |
| 25 | +class AddConsoleCommandPass extends BaseAddConsoleCommandPass |
28 | 26 | {
|
29 |
| - public function process(ContainerBuilder $container) |
30 |
| - { |
31 |
| - $commandServices = $container->findTaggedServiceIds('console.command'); |
32 |
| - $serviceIds = array(); |
33 |
| - |
34 |
| - foreach ($commandServices as $id => $tags) { |
35 |
| - $definition = $container->getDefinition($id); |
36 |
| - |
37 |
| - if ($definition->isAbstract()) { |
38 |
| - throw new InvalidArgumentException(sprintf('The service "%s" tagged "console.command" must not be abstract.', $id)); |
39 |
| - } |
40 |
| - |
41 |
| - $class = $container->getParameterBag()->resolveValue($definition->getClass()); |
42 |
| - if (!is_subclass_of($class, 'Symfony\\Component\\Console\\Command\\Command')) { |
43 |
| - if (!class_exists($class, false)) { |
44 |
| - throw new InvalidArgumentException(sprintf('Class "%s" used for service "%s" cannot be found.', $class, $id)); |
45 |
| - } |
46 |
| - |
47 |
| - throw new InvalidArgumentException(sprintf('The service "%s" tagged "console.command" must be a subclass of "Symfony\\Component\\Console\\Command\\Command".', $id)); |
48 |
| - } |
49 |
| - $container->setAlias($serviceId = 'console.command.'.strtolower(str_replace('\\', '_', $class)), $id); |
50 |
| - $serviceIds[] = $definition->isPublic() ? $id : $serviceId; |
51 |
| - } |
52 |
| - |
53 |
| - $container->setParameter('console.command.ids', $serviceIds); |
54 |
| - } |
55 | 27 | }
|
0 commit comments