From a7386142ca8c935c0e0a759f3eb839e96458719d Mon Sep 17 00:00:00 2001 From: eltharin Date: Fri, 27 Sep 2024 11:49:44 +0200 Subject: [PATCH] allow command security:custom with name in argument to no interraction --- src/Maker/Security/MakeCustomAuthenticator.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Maker/Security/MakeCustomAuthenticator.php b/src/Maker/Security/MakeCustomAuthenticator.php index c3ecae946..b5e1b3d2b 100644 --- a/src/Maker/Security/MakeCustomAuthenticator.php +++ b/src/Maker/Security/MakeCustomAuthenticator.php @@ -24,6 +24,7 @@ use Symfony\Bundle\MakerBundle\Util\YamlSourceManipulator; use Symfony\Bundle\MakerBundle\Validator; use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; @@ -68,8 +69,10 @@ public static function getCommandDescription(): string public function configureCommand(Command $command, InputConfiguration $inputConfig): void { $command + ->addArgument('name', InputArgument::OPTIONAL, 'The class name of the authenticator (e.g. CustomAuthenticator)') ->setHelp($this->getHelpFileContents('security/MakeCustom.txt')) ; + $inputConfig->setArgumentAsNonInteractive('name'); } public function interact(InputInterface $input, ConsoleStyle $io, Command $command): void @@ -84,7 +87,7 @@ public function interact(InputInterface $input, ConsoleStyle $io, Command $comma throw new RuntimeCommandException(\sprintf('The file "%s" does not exist. PHP & XML configuration formats are currently not supported.', self::SECURITY_CONFIG_PATH)); } - $name = $io->ask( + $name = $input->getArgument('name') ?? $io->ask( question: 'What is the class name of the authenticator (e.g. CustomAuthenticator)', validator: static function (mixed $answer) { return Validator::notBlank($answer);