|
1
|
|
|
<?php |
|
2
|
|
|
declare(strict_types=1); |
|
3
|
|
|
/** |
|
4
|
|
|
* @copyright Copyright (c) 2019 Arthur Schiwon <[email protected]> |
|
5
|
|
|
* |
|
6
|
|
|
* @author Arthur Schiwon <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* @license GNU AGPL version 3 or any later version |
|
9
|
|
|
* |
|
10
|
|
|
* This program is free software: you can redistribute it and/or modify |
|
11
|
|
|
* it under the terms of the GNU Affero General Public License as |
|
12
|
|
|
* published by the Free Software Foundation, either version 3 of the |
|
13
|
|
|
* License, or (at your option) any later version. |
|
14
|
|
|
* |
|
15
|
|
|
* This program is distributed in the hope that it will be useful, |
|
16
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
18
|
|
|
* GNU Affero General Public License for more details. |
|
19
|
|
|
* |
|
20
|
|
|
* You should have received a copy of the GNU Affero General Public License |
|
21
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
22
|
|
|
* |
|
23
|
|
|
*/ |
|
24
|
|
|
|
|
25
|
|
|
namespace OCA\WorkflowEngine\Command; |
|
26
|
|
|
|
|
27
|
|
|
use OCA\WorkflowEngine\Helper\ScopeContext; |
|
28
|
|
|
use OCA\WorkflowEngine\Manager; |
|
29
|
|
|
use OCP\WorkflowEngine\IManager; |
|
30
|
|
|
use Symfony\Component\Console\Command\Command; |
|
31
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
|
32
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
33
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
34
|
|
|
|
|
35
|
|
|
class Index extends Command { |
|
36
|
|
|
|
|
37
|
|
|
/** @var Manager */ |
|
38
|
|
|
private $manager; |
|
39
|
|
|
|
|
40
|
|
|
public function __construct(Manager $manager) { |
|
41
|
|
|
$this->manager = $manager; |
|
42
|
|
|
parent::__construct(); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
protected function configure() { |
|
46
|
|
|
$this |
|
47
|
|
|
->setName('workflows:list') |
|
48
|
|
|
->setDescription('Lists configured workflows') |
|
49
|
|
|
->addArgument( |
|
50
|
|
|
'scope', |
|
51
|
|
|
InputArgument::OPTIONAL, |
|
52
|
|
|
'Lists workflows for "admin", "user"', |
|
53
|
|
|
'admin' |
|
54
|
|
|
) |
|
55
|
|
|
->addArgument( |
|
56
|
|
|
'scopeId', |
|
57
|
|
|
InputArgument::OPTIONAL, |
|
58
|
|
|
'User IDs when the scope is "user"', |
|
59
|
|
|
null |
|
60
|
|
|
); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
protected function mappedScope(string $scope): int { |
|
64
|
|
|
static $scopes = [ |
|
65
|
|
|
'admin' => IManager::SCOPE_ADMIN, |
|
66
|
|
|
'user' => IManager::SCOPE_USER, |
|
67
|
|
|
]; |
|
68
|
|
|
return $scopes[$scope] ?? -1; |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) { |
|
72
|
|
|
$ops = $this->manager->getAllOperations( |
|
73
|
|
|
new ScopeContext( |
|
74
|
|
|
$this->mappedScope($input->getArgument('scope')), |
|
75
|
|
|
$input->getArgument('scopeId') |
|
76
|
|
|
) |
|
77
|
|
|
); |
|
78
|
|
|
$output->writeln(\json_encode($ops)); |
|
79
|
|
|
} |
|
80
|
|
|
} |
|
81
|
|
|
|