Skip to content

Commit b6d4072

Browse files
ycerutochalasr
authored andcommitted
Add support for invokable commands and input attributes
1 parent d7c53f7 commit b6d4072

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

DependencyInjection/FrameworkExtension.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
use Symfony\Component\Config\Resource\FileResource;
5050
use Symfony\Component\Config\ResourceCheckerInterface;
5151
use Symfony\Component\Console\Application;
52+
use Symfony\Component\Console\Attribute\AsCommand;
5253
use Symfony\Component\Console\Command\Command;
5354
use Symfony\Component\Console\DataCollector\CommandDataCollector;
5455
use Symfony\Component\Console\Debug\CliRequest;
@@ -608,6 +609,9 @@ public function load(array $configs, ContainerBuilder $container): void
608609
->addTag('assets.package');
609610
$container->registerForAutoconfiguration(AssetCompilerInterface::class)
610611
->addTag('asset_mapper.compiler');
612+
$container->registerAttributeForAutoconfiguration(AsCommand::class, static function (ChildDefinition $definition, AsCommand $attribute, \ReflectionClass $reflector): void {
613+
$definition->addTag('console.command', ['command' => $attribute->name, 'description' => $attribute->description ?? $reflector->getName()]);
614+
});
611615
$container->registerForAutoconfiguration(Command::class)
612616
->addTag('console.command');
613617
$container->registerForAutoconfiguration(ResourceCheckerInterface::class)

0 commit comments

Comments
 (0)