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