setName('oauth2:add-client');
$this->setDescription('This command adds a new oauth2 client.');
$this->addArgument(
self::ARGUMENT_CLIENT_NAME,
InputArgument::REQUIRED,
'Name of the oauth2 client',
);
$this->addArgument(
self::ARGUMENT_CLIENT_REDIRECT_URI,
InputArgument::REQUIRED,
'Redirection uri of the oauth2 client ',
);
}
#[\Override]
protected function execute(InputInterface $input, OutputInterface $output): int {
/** @var string $name */
$name = $input->getArgument(self::ARGUMENT_CLIENT_NAME);
/** @var string $redirectUri */
$redirectUri = $input->getArgument(self::ARGUMENT_CLIENT_REDIRECT_URI);
// Should not happen but just to be sure
if (empty($redirectUri) || empty($name)) {
$output->writeln('Redirect uri or name is empty');
return Command::FAILURE;
}
if (filter_var($redirectUri, FILTER_VALIDATE_URL) === false) {
$output->writeln('Your redirect URL needs to be a full URL for example: https://yourdomain.com/path');
return Command::FAILURE;
}
$result = $this->clientService->addClient($name, $redirectUri);
$this->writeArrayInOutputFormat($input, $output, $result);
return Command::SUCCESS;
}
}