|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace OAuth\Command; |
|
4
|
|
|
|
|
5
|
|
|
use Del\Service\UserService; |
|
6
|
|
|
use OAuth\Client; |
|
7
|
|
|
use OAuth\Repository\ScopeRepository; |
|
8
|
|
|
use OAuth\Scope; |
|
9
|
|
|
use OAuth\Service\ClientService; |
|
10
|
|
|
use OAuth\OAuthUser as User; |
|
11
|
|
|
use Symfony\Component\Console\Command\Command; |
|
12
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
13
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
14
|
|
|
use Symfony\Component\Console\Question\ChoiceQuestion; |
|
15
|
|
|
use Symfony\Component\Console\Question\ConfirmationQuestion; |
|
16
|
|
|
use Symfony\Component\Console\Question\Question; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Class ScopeListCommand |
|
20
|
|
|
* @package OAuth\Command |
|
21
|
|
|
*/ |
|
22
|
|
|
class ScopeListCommand extends Command |
|
23
|
|
|
{ |
|
24
|
|
|
/** |
|
25
|
|
|
* @var ScopeRepository $scopeRepository |
|
26
|
|
|
*/ |
|
27
|
|
|
private $scopeRepository; |
|
28
|
|
|
|
|
29
|
|
|
public function __construct(ScopeRepository $scopeRepository, ?string $name = null) |
|
30
|
|
|
{ |
|
31
|
|
|
$this->scopeRepository = $scopeRepository; |
|
32
|
|
|
parent::__construct($name); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* configure options |
|
37
|
|
|
*/ |
|
38
|
|
|
protected function configure() |
|
39
|
|
|
{ |
|
40
|
|
|
$this->setName('scope:list'); |
|
41
|
|
|
$this->setDescription('Lists all scopes.'); |
|
42
|
|
|
$this->setHelp('Lists available access scopes.'); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* @param InputInterface $input |
|
47
|
|
|
* @param OutputInterface $output |
|
48
|
|
|
* @throws \Doctrine\ORM\OptimisticLockException |
|
49
|
|
|
*/ |
|
50
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
|
51
|
|
|
{ |
|
52
|
|
|
$output->writeln('Listing scopes...'); |
|
53
|
|
|
$scopes = $this->scopeRepository->findAll(); |
|
54
|
|
|
if (!count($scopes)) { |
|
55
|
|
|
$output->writeln('No scopes found.'); |
|
56
|
|
|
} |
|
57
|
|
|
/** @var Scope $scope */ |
|
58
|
|
|
foreach ($scopes as $scope) { |
|
59
|
|
|
$output->writeln(' - ' . $scope->getIdentifier()); |
|
60
|
|
|
} |
|
61
|
|
|
} |
|
62
|
|
|
} |