|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Command; |
|
4
|
|
|
|
|
5
|
|
|
use App\Entity\Client; |
|
6
|
|
|
use Symfony\Component\Console\Command\Command; |
|
7
|
|
|
use Symfony\Component\Console\Helper\Table; |
|
8
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
|
9
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
10
|
|
|
use Symfony\Component\Console\Input\InputOption; |
|
11
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
12
|
|
|
use Symfony\Component\Console\Question\ChoiceQuestion; |
|
13
|
|
|
use Symfony\Component\Console\Style\SymfonyStyle; |
|
14
|
|
|
use Symfony\Component\DependencyInjection\ContainerAwareInterface; |
|
15
|
|
|
use Symfony\Component\DependencyInjection\ContainerInterface; |
|
16
|
|
|
|
|
17
|
|
|
class ClientListCommand extends Command |
|
18
|
|
|
{ |
|
19
|
|
|
protected static $defaultName = 'api:client:list'; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* @var ContainerInterface |
|
23
|
|
|
*/ |
|
24
|
|
|
private $container; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* ApiCreateClientCommand constructor. |
|
28
|
|
|
* @param ContainerInterface $container |
|
29
|
|
|
*/ |
|
30
|
1 |
|
public function __construct(ContainerInterface $container) |
|
31
|
|
|
{ |
|
32
|
1 |
|
$this->container = $container; |
|
33
|
1 |
|
parent::__construct(); |
|
34
|
1 |
|
} |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* |
|
38
|
|
|
* @throws \Symfony\Component\Console\Exception\InvalidArgumentException |
|
39
|
|
|
*/ |
|
40
|
1 |
|
protected function configure() |
|
41
|
|
|
{ |
|
42
|
|
|
$this |
|
43
|
1 |
|
->setName('api:client:list') |
|
44
|
1 |
|
->setDescription('Lists current API clients.'); |
|
45
|
1 |
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* @param InputInterface $input |
|
49
|
|
|
* @param OutputInterface $output |
|
50
|
|
|
* @return int|null|void |
|
51
|
|
|
* @throws \Symfony\Component\Console\Exception\InvalidArgumentException |
|
52
|
|
|
* @throws \Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException |
|
53
|
|
|
*/ |
|
54
|
1 |
|
protected function execute(InputInterface $input, OutputInterface $output) |
|
55
|
|
|
{ |
|
56
|
1 |
|
$clients = $this->container->get('doctrine')->getRepository(Client::class)->findAll(); |
|
57
|
1 |
|
$table = new Table($output); |
|
58
|
1 |
|
$table->setHeaders(['ID', 'Key', 'Secret', 'Grant Types', 'Redirect URIs']); |
|
59
|
|
|
/** @var Client $client */ |
|
60
|
1 |
|
foreach($clients as $client) { |
|
61
|
|
|
$table->addRow([ |
|
62
|
|
|
'id' => $client->getId(), |
|
63
|
|
|
'key' => $client->getPublicId(), |
|
64
|
|
|
'secret' => $client->getSecret(), |
|
65
|
|
|
'grant_types' => implode(',', $client->getAllowedGrantTypes()), |
|
66
|
|
|
'redirect_uris' => implode(',', $client->getRedirectUris()), |
|
67
|
|
|
]); |
|
68
|
|
|
} |
|
69
|
1 |
|
$table->render(); |
|
70
|
1 |
|
} |
|
71
|
|
|
|
|
72
|
|
|
} |
|
73
|
|
|
|