apiKeyService = $apiKeyService; $this->translator = $translator; parent::__construct(); } public function configure() { $this->setName(self::NAME) ->setDescription($this->translator->translate('Generates a new valid API key.')) ->addOption( 'expirationDate', 'e', InputOption::VALUE_OPTIONAL, $this->translator->translate('The date in which the API key should expire. Use any valid PHP format.') ); } public function execute(InputInterface $input, OutputInterface $output) { $expirationDate = $input->getOption('expirationDate'); $apiKey = $this->apiKeyService->create(isset($expirationDate) ? Chronos::parse($expirationDate) : null); (new SymfonyStyle($input, $output))->success( sprintf($this->translator->translate('Generated API key: "%s"'), $apiKey) ); } }