@@ -32,81 +32,81 @@ |
||
32 | 32 | use Symfony\Component\Console\Output\OutputInterface; |
33 | 33 | |
34 | 34 | class ListCommand extends Base { |
35 | - protected IGroupManager $groupManager; |
|
35 | + protected IGroupManager $groupManager; |
|
36 | 36 | |
37 | - public function __construct(IGroupManager $groupManager) { |
|
38 | - $this->groupManager = $groupManager; |
|
39 | - parent::__construct(); |
|
40 | - } |
|
37 | + public function __construct(IGroupManager $groupManager) { |
|
38 | + $this->groupManager = $groupManager; |
|
39 | + parent::__construct(); |
|
40 | + } |
|
41 | 41 | |
42 | - protected function configure() { |
|
43 | - $this |
|
44 | - ->setName('group:list') |
|
45 | - ->setDescription('list configured groups') |
|
46 | - ->addOption( |
|
47 | - 'limit', |
|
48 | - 'l', |
|
49 | - InputOption::VALUE_OPTIONAL, |
|
50 | - 'Number of groups to retrieve', |
|
51 | - '500' |
|
52 | - )->addOption( |
|
53 | - 'offset', |
|
54 | - 'o', |
|
55 | - InputOption::VALUE_OPTIONAL, |
|
56 | - 'Offset for retrieving groups', |
|
57 | - '0' |
|
58 | - )->addOption( |
|
59 | - 'info', |
|
60 | - 'i', |
|
61 | - InputOption::VALUE_NONE, |
|
62 | - 'Show additional info (backend)' |
|
63 | - )->addOption( |
|
64 | - 'output', |
|
65 | - null, |
|
66 | - InputOption::VALUE_OPTIONAL, |
|
67 | - 'Output format (plain, json or json_pretty, default is plain)', |
|
68 | - $this->defaultOutputFormat |
|
69 | - ); |
|
70 | - } |
|
42 | + protected function configure() { |
|
43 | + $this |
|
44 | + ->setName('group:list') |
|
45 | + ->setDescription('list configured groups') |
|
46 | + ->addOption( |
|
47 | + 'limit', |
|
48 | + 'l', |
|
49 | + InputOption::VALUE_OPTIONAL, |
|
50 | + 'Number of groups to retrieve', |
|
51 | + '500' |
|
52 | + )->addOption( |
|
53 | + 'offset', |
|
54 | + 'o', |
|
55 | + InputOption::VALUE_OPTIONAL, |
|
56 | + 'Offset for retrieving groups', |
|
57 | + '0' |
|
58 | + )->addOption( |
|
59 | + 'info', |
|
60 | + 'i', |
|
61 | + InputOption::VALUE_NONE, |
|
62 | + 'Show additional info (backend)' |
|
63 | + )->addOption( |
|
64 | + 'output', |
|
65 | + null, |
|
66 | + InputOption::VALUE_OPTIONAL, |
|
67 | + 'Output format (plain, json or json_pretty, default is plain)', |
|
68 | + $this->defaultOutputFormat |
|
69 | + ); |
|
70 | + } |
|
71 | 71 | |
72 | - protected function execute(InputInterface $input, OutputInterface $output): int { |
|
73 | - $groups = $this->groupManager->search('', (int)$input->getOption('limit'), (int)$input->getOption('offset')); |
|
74 | - $this->writeArrayInOutputFormat($input, $output, $this->formatGroups($groups, (bool)$input->getOption('info'))); |
|
75 | - return 0; |
|
76 | - } |
|
72 | + protected function execute(InputInterface $input, OutputInterface $output): int { |
|
73 | + $groups = $this->groupManager->search('', (int)$input->getOption('limit'), (int)$input->getOption('offset')); |
|
74 | + $this->writeArrayInOutputFormat($input, $output, $this->formatGroups($groups, (bool)$input->getOption('info'))); |
|
75 | + return 0; |
|
76 | + } |
|
77 | 77 | |
78 | - /** |
|
79 | - * @param IGroup $group |
|
80 | - * @return string[] |
|
81 | - */ |
|
82 | - public function usersForGroup(IGroup $group) { |
|
83 | - $users = array_keys($group->getUsers()); |
|
84 | - return array_map(function ($userId) { |
|
85 | - return (string)$userId; |
|
86 | - }, $users); |
|
87 | - } |
|
78 | + /** |
|
79 | + * @param IGroup $group |
|
80 | + * @return string[] |
|
81 | + */ |
|
82 | + public function usersForGroup(IGroup $group) { |
|
83 | + $users = array_keys($group->getUsers()); |
|
84 | + return array_map(function ($userId) { |
|
85 | + return (string)$userId; |
|
86 | + }, $users); |
|
87 | + } |
|
88 | 88 | |
89 | - /** |
|
90 | - * @param IGroup[] $groups |
|
91 | - * @return array |
|
92 | - */ |
|
93 | - private function formatGroups(array $groups, bool $addInfo = false) { |
|
94 | - $keys = array_map(function (IGroup $group) { |
|
95 | - return $group->getGID(); |
|
96 | - }, $groups); |
|
89 | + /** |
|
90 | + * @param IGroup[] $groups |
|
91 | + * @return array |
|
92 | + */ |
|
93 | + private function formatGroups(array $groups, bool $addInfo = false) { |
|
94 | + $keys = array_map(function (IGroup $group) { |
|
95 | + return $group->getGID(); |
|
96 | + }, $groups); |
|
97 | 97 | |
98 | - if ($addInfo) { |
|
99 | - $values = array_map(function (IGroup $group) { |
|
100 | - return [ |
|
101 | - 'backends' => $group->getBackendNames(), |
|
102 | - 'users' => $this->usersForGroup($group), |
|
103 | - ]; |
|
104 | - }, $groups); |
|
105 | - } else { |
|
106 | - $values = array_map(function (IGroup $group) { |
|
107 | - return $this->usersForGroup($group); |
|
108 | - }, $groups); |
|
109 | - } |
|
110 | - return array_combine($keys, $values); |
|
111 | - } |
|
98 | + if ($addInfo) { |
|
99 | + $values = array_map(function (IGroup $group) { |
|
100 | + return [ |
|
101 | + 'backends' => $group->getBackendNames(), |
|
102 | + 'users' => $this->usersForGroup($group), |
|
103 | + ]; |
|
104 | + }, $groups); |
|
105 | + } else { |
|
106 | + $values = array_map(function (IGroup $group) { |
|
107 | + return $this->usersForGroup($group); |
|
108 | + }, $groups); |
|
109 | + } |
|
110 | + return array_combine($keys, $values); |
|
111 | + } |
|
112 | 112 | } |
@@ -70,8 +70,8 @@ discard block |
||
70 | 70 | } |
71 | 71 | |
72 | 72 | protected function execute(InputInterface $input, OutputInterface $output): int { |
73 | - $groups = $this->groupManager->search('', (int)$input->getOption('limit'), (int)$input->getOption('offset')); |
|
74 | - $this->writeArrayInOutputFormat($input, $output, $this->formatGroups($groups, (bool)$input->getOption('info'))); |
|
73 | + $groups = $this->groupManager->search('', (int) $input->getOption('limit'), (int) $input->getOption('offset')); |
|
74 | + $this->writeArrayInOutputFormat($input, $output, $this->formatGroups($groups, (bool) $input->getOption('info'))); |
|
75 | 75 | return 0; |
76 | 76 | } |
77 | 77 | |
@@ -81,8 +81,8 @@ discard block |
||
81 | 81 | */ |
82 | 82 | public function usersForGroup(IGroup $group) { |
83 | 83 | $users = array_keys($group->getUsers()); |
84 | - return array_map(function ($userId) { |
|
85 | - return (string)$userId; |
|
84 | + return array_map(function($userId) { |
|
85 | + return (string) $userId; |
|
86 | 86 | }, $users); |
87 | 87 | } |
88 | 88 | |
@@ -91,19 +91,19 @@ discard block |
||
91 | 91 | * @return array |
92 | 92 | */ |
93 | 93 | private function formatGroups(array $groups, bool $addInfo = false) { |
94 | - $keys = array_map(function (IGroup $group) { |
|
94 | + $keys = array_map(function(IGroup $group) { |
|
95 | 95 | return $group->getGID(); |
96 | 96 | }, $groups); |
97 | 97 | |
98 | 98 | if ($addInfo) { |
99 | - $values = array_map(function (IGroup $group) { |
|
99 | + $values = array_map(function(IGroup $group) { |
|
100 | 100 | return [ |
101 | 101 | 'backends' => $group->getBackendNames(), |
102 | 102 | 'users' => $this->usersForGroup($group), |
103 | 103 | ]; |
104 | 104 | }, $groups); |
105 | 105 | } else { |
106 | - $values = array_map(function (IGroup $group) { |
|
106 | + $values = array_map(function(IGroup $group) { |
|
107 | 107 | return $this->usersForGroup($group); |
108 | 108 | }, $groups); |
109 | 109 | } |