Skip to content

Commit 993332e

Browse files
committed
Move AddConsoleCommandPass from FrameworkBundle to Console.
1 parent b60dcaf commit 993332e

File tree

5 files changed

+15
-34
lines changed

5 files changed

+15
-34
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ CHANGELOG
1111
* Translation related services are not loaded anymore when the `framework.translator` option
1212
is disabled.
1313
* Added `GlobalVariables::getToken()`
14+
* Deprecated `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddConsoleCommandPass`. Use `Symfony\Component\Console\DependencyInjection\AddConsoleCommandPass` instead.
1415

1516
3.2.0
1617
-----

DependencyInjection/Compiler/AddConsoleCommandPass.php

Lines changed: 7 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -11,41 +11,17 @@
1111

1212
namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler;
1313

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;
1717

1818
/**
19-
* AddConsoleCommandPass.
19+
* Registers console commands.
2020
*
2121
* @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.
2224
*/
23-
class AddConsoleCommandPass implements CompilerPassInterface
25+
class AddConsoleCommandPass extends BaseAddConsoleCommandPass
2426
{
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-
}
5127
}

FrameworkBundle.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddConstraintValidatorsPass;
1515
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddDebugLogProcessorPass;
1616
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddValidatorInitializersPass;
17-
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddConsoleCommandPass;
1817
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\CachePoolPass;
1918
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\CachePoolClearerPass;
2019
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ControllerArgumentValueResolverPass;
@@ -36,6 +35,7 @@
3635
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\UnusedTagsPass;
3736
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ConfigCachePass;
3837
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ValidateWorkflowsPass;
38+
use Symfony\Component\Console\DependencyInjection\AddConsoleCommandPass;
3939
use Symfony\Component\Debug\ErrorHandler;
4040
use Symfony\Component\DependencyInjection\ContainerBuilder;
4141
use Symfony\Component\DependencyInjection\Compiler\PassConfig;

Tests/DependencyInjection/Compiler/AddConsoleCommandPassTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
use Symfony\Component\DependencyInjection\Definition;
1818
use Symfony\Component\HttpKernel\Bundle\Bundle;
1919

20+
/**
21+
* @group legacy
22+
*/
2023
class AddConsoleCommandPassTest extends \PHPUnit_Framework_TestCase
2124
{
2225
/**

composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"require-dev": {
3535
"symfony/asset": "~2.8|~3.0",
3636
"symfony/browser-kit": "~2.8|~3.0",
37-
"symfony/console": "~2.8.8|~3.0.8|~3.1.2|~3.2",
37+
"symfony/console": "~3.3",
3838
"symfony/css-selector": "~2.8|~3.0",
3939
"symfony/dom-crawler": "~2.8|~3.0",
4040
"symfony/polyfill-intl-icu": "~1.0",
@@ -56,7 +56,8 @@
5656
},
5757
"conflict": {
5858
"phpdocumentor/reflection-docblock": "<3.0",
59-
"phpdocumentor/type-resolver": "<0.2.0"
59+
"phpdocumentor/type-resolver": "<0.2.0",
60+
"symfony/console": "<3.3"
6061
},
6162
"suggest": {
6263
"ext-apcu": "For best performance of the system caches",

0 commit comments

Comments
 (0)