-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature #13369 [Command] add command to generate jwt (SirDomin)
This PR was merged into the 1.11-dev branch. Discussion ---------- | Q | A | --------------- | ----- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Related tickets | | License | MIT ![image](https://user-images.githubusercontent.com/22825722/145157836-76155d82-7a00-44e0-9b21-603148836ff7.png) <!-- - Bug fixes must be submitted against the 1.10 branch - Features and deprecations must be submitted against the master branch - Make sure that the correct base branch is set To be sure you are not breaking any Backward Compatibilities, check the documentation: https://docs.sylius.com/en/latest/book/organization/backward-compatibility-promise.html --> Commits ------- f8348e9 [Command] add command to generate jwt 33a3d4e [Command] make command more consistent, add info to docs
- Loading branch information
Showing
4 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
src/Sylius/Bundle/CoreBundle/Command/JwtConfigurationCommand.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Sylius package. | ||
* | ||
* (c) Paweł Jędrzejewski | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Sylius\Bundle\CoreBundle\Command; | ||
|
||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
use Symfony\Component\Console\Question\ConfirmationQuestion; | ||
|
||
final class JwtConfigurationCommand extends AbstractInstallCommand | ||
{ | ||
protected static $defaultName = 'sylius:install:jwt-setup'; | ||
|
||
protected function configure(): void | ||
{ | ||
$this | ||
->setDescription('Setup JWT token') | ||
->setHelp( | ||
<<<EOT | ||
The <info>%command.name%</info> command generates JWT token. | ||
EOT | ||
) | ||
; | ||
} | ||
|
||
protected function execute(InputInterface $input, OutputInterface $output): int | ||
{ | ||
$helper = $this->getHelper('question'); | ||
|
||
$output->writeln('Generating JWT token for Sylius API'); | ||
|
||
$question = new ConfirmationQuestion('Do you want to generate JWT token? (y/N)', false); | ||
|
||
if (!$helper->ask($input, $output, $question)) { | ||
return 0; | ||
} | ||
|
||
$this->commandExecutor->runCommand('lexik:jwt:generate-keypair', ['--overwrite' => true], $output); | ||
|
||
$output->writeln('Please, remember to enable Sylius API'); | ||
$output->writeln('https://docs.sylius.com/en/1.10/book/api/introduction.html'); | ||
|
||
return 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters