mirror of
https://github.com/shlinkio/shlink.git
synced 2025-03-31 13:54:55 +03:00
45 lines
1.2 KiB
PHP
45 lines
1.2 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
namespace Shlinkio\Shlink\CLI\Command\Config;
|
|
|
|
use Shlinkio\Shlink\Common\Util\StringUtilsTrait;
|
|
use Symfony\Component\Console\Command\Command;
|
|
use Symfony\Component\Console\Input\InputInterface;
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
|
use Symfony\Component\Console\Style\SymfonyStyle;
|
|
use Zend\I18n\Translator\TranslatorInterface;
|
|
|
|
class GenerateSecretCommand extends Command
|
|
{
|
|
use StringUtilsTrait;
|
|
|
|
const NAME = 'config:generate-secret';
|
|
|
|
/**
|
|
* @var TranslatorInterface
|
|
*/
|
|
private $translator;
|
|
|
|
public function __construct(TranslatorInterface $translator)
|
|
{
|
|
$this->translator = $translator;
|
|
parent::__construct();
|
|
}
|
|
|
|
public function configure()
|
|
{
|
|
$this->setName(self::NAME)
|
|
->setDescription($this->translator->translate(
|
|
'Generates a random secret string that can be used for JWT token encryption'
|
|
));
|
|
}
|
|
|
|
public function execute(InputInterface $input, OutputInterface $output)
|
|
{
|
|
$secret = $this->generateRandomString(32);
|
|
(new SymfonyStyle($input, $output))->success(
|
|
sprintf($this->translator->translate('Secret key: "%s"'), $secret)
|
|
);
|
|
}
|
|
}
|