angelov /
donut
| 1 | <?php |
||||
| 2 | |||||
| 3 | /** |
||||
| 4 | * Donut Social Network - Yet another experimental social network. |
||||
| 5 | * Copyright (C) 2016-2018, Dejan Angelov <[email protected]> |
||||
| 6 | * |
||||
| 7 | * This file is part of Donut Social Network. |
||||
| 8 | * |
||||
| 9 | * Donut Social Network is free software: you can redistribute it and/or modify |
||||
| 10 | * it under the terms of the GNU General Public License as published by |
||||
| 11 | * the Free Software Foundation, either version 3 of the License, or |
||||
| 12 | * (at your option) any later version. |
||||
| 13 | * |
||||
| 14 | * Donut Social Network is distributed in the hope that it will be useful, |
||||
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
| 17 | * GNU General Public License for more details. |
||||
| 18 | * |
||||
| 19 | * You should have received a copy of the GNU General Public License |
||||
| 20 | * along with Donut Social Network. If not, see <http://www.gnu.org/licenses/>. |
||||
| 21 | * |
||||
| 22 | * @package Donut Social Network |
||||
| 23 | * @copyright Copyright (C) 2016-2018, Dejan Angelov <[email protected]> |
||||
| 24 | * @license https://github.com/angelov/donut/blob/master/LICENSE |
||||
| 25 | * @author Dejan Angelov <[email protected]> |
||||
| 26 | */ |
||||
| 27 | |||||
| 28 | namespace ApiBundle\Console; |
||||
| 29 | |||||
| 30 | use FOS\OAuthServerBundle\Model\ClientManagerInterface; |
||||
| 31 | use Symfony\Component\Console\Command\Command; |
||||
| 32 | use Symfony\Component\Console\Input\InputInterface; |
||||
| 33 | use Symfony\Component\Console\Input\InputOption; |
||||
| 34 | use Symfony\Component\Console\Output\OutputInterface; |
||||
| 35 | |||||
| 36 | class CreateClientCommand extends Command |
||||
| 37 | { |
||||
| 38 | private $clientManager; |
||||
| 39 | |||||
| 40 | public function __construct(ClientManagerInterface $clientManager) |
||||
| 41 | { |
||||
| 42 | parent::__construct(); |
||||
| 43 | |||||
| 44 | $this->clientManager = $clientManager; |
||||
| 45 | } |
||||
| 46 | |||||
| 47 | protected function configure() : void |
||||
| 48 | { |
||||
| 49 | $this |
||||
| 50 | ->setName('api:create-client') |
||||
| 51 | ->addOption( |
||||
| 52 | 'redirect-uri', |
||||
| 53 | null, |
||||
| 54 | InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, |
||||
| 55 | 'Sets redirect uri for client.' |
||||
| 56 | ) |
||||
| 57 | ->addOption( |
||||
| 58 | 'grant-type', |
||||
| 59 | null, |
||||
| 60 | InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, |
||||
| 61 | 'Sets allowed grant type for client.' |
||||
| 62 | ); |
||||
| 63 | } |
||||
| 64 | |||||
| 65 | protected function execute(InputInterface $input, OutputInterface $output) |
||||
| 66 | { |
||||
| 67 | $client = $this->clientManager->createClient(); |
||||
| 68 | |||||
| 69 | $client->setRedirectUris($input->getOption('redirect-uri')); |
||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||
| 70 | $client->setAllowedGrantTypes($input->getOption('grant-type')); |
||||
|
0 ignored issues
–
show
It seems like
$input->getOption('grant-type') can also be of type boolean and null and string; however, parameter $grantTypes of FOS\OAuthServerBundle\Mo...:setAllowedGrantTypes() does only seem to accept array, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 71 | |||||
| 72 | $this->clientManager->updateClient($client); |
||||
| 73 | |||||
| 74 | $output->writeln(sprintf( |
||||
| 75 | 'Added a new client with public id <info>%s</info> and secret <info>%s</info>.', |
||||
| 76 | $client->getPublicId(), |
||||
| 77 | $client->getSecret() |
||||
| 78 | )); |
||||
| 79 | } |
||||
| 80 | } |
||||
| 81 |