@@ -29,48 +29,48 @@ |
||
29 | 29 | use Symfony\Component\Console\Output\OutputInterface; |
30 | 30 | |
31 | 31 | class GetPath extends Base { |
32 | - protected function configure() { |
|
33 | - parent::configure(); |
|
32 | + protected function configure() { |
|
33 | + parent::configure(); |
|
34 | 34 | |
35 | - $this |
|
36 | - ->setName('app:getpath') |
|
37 | - ->setDescription('Get an absolute path to the app directory') |
|
38 | - ->addArgument( |
|
39 | - 'app', |
|
40 | - InputArgument::REQUIRED, |
|
41 | - 'Name of the app' |
|
42 | - ) |
|
43 | - ; |
|
44 | - } |
|
35 | + $this |
|
36 | + ->setName('app:getpath') |
|
37 | + ->setDescription('Get an absolute path to the app directory') |
|
38 | + ->addArgument( |
|
39 | + 'app', |
|
40 | + InputArgument::REQUIRED, |
|
41 | + 'Name of the app' |
|
42 | + ) |
|
43 | + ; |
|
44 | + } |
|
45 | 45 | |
46 | - /** |
|
47 | - * Executes the current command. |
|
48 | - * |
|
49 | - * @param InputInterface $input An InputInterface instance |
|
50 | - * @param OutputInterface $output An OutputInterface instance |
|
51 | - * @return null|int null or 0 if everything went fine, or an error code |
|
52 | - */ |
|
53 | - protected function execute(InputInterface $input, OutputInterface $output) { |
|
54 | - $appName = $input->getArgument('app'); |
|
55 | - $path = \OC_App::getAppPath($appName); |
|
56 | - if ($path !== false) { |
|
57 | - $output->writeln($path); |
|
58 | - return 0; |
|
59 | - } |
|
46 | + /** |
|
47 | + * Executes the current command. |
|
48 | + * |
|
49 | + * @param InputInterface $input An InputInterface instance |
|
50 | + * @param OutputInterface $output An OutputInterface instance |
|
51 | + * @return null|int null or 0 if everything went fine, or an error code |
|
52 | + */ |
|
53 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
54 | + $appName = $input->getArgument('app'); |
|
55 | + $path = \OC_App::getAppPath($appName); |
|
56 | + if ($path !== false) { |
|
57 | + $output->writeln($path); |
|
58 | + return 0; |
|
59 | + } |
|
60 | 60 | |
61 | - // App not found, exit with non-zero |
|
62 | - return 1; |
|
63 | - } |
|
61 | + // App not found, exit with non-zero |
|
62 | + return 1; |
|
63 | + } |
|
64 | 64 | |
65 | - /** |
|
66 | - * @param string $argumentName |
|
67 | - * @param CompletionContext $context |
|
68 | - * @return string[] |
|
69 | - */ |
|
70 | - public function completeArgumentValues($argumentName, CompletionContext $context) { |
|
71 | - if ($argumentName === 'app') { |
|
72 | - return \OC_App::getAllApps(); |
|
73 | - } |
|
74 | - return []; |
|
75 | - } |
|
65 | + /** |
|
66 | + * @param string $argumentName |
|
67 | + * @param CompletionContext $context |
|
68 | + * @return string[] |
|
69 | + */ |
|
70 | + public function completeArgumentValues($argumentName, CompletionContext $context) { |
|
71 | + if ($argumentName === 'app') { |
|
72 | + return \OC_App::getAllApps(); |
|
73 | + } |
|
74 | + return []; |
|
75 | + } |
|
76 | 76 | } |
@@ -30,30 +30,30 @@ |
||
30 | 30 | |
31 | 31 | class ShowKeyStorageRoot extends Command{ |
32 | 32 | |
33 | - /** @var Util */ |
|
34 | - protected $util; |
|
35 | - |
|
36 | - /** |
|
37 | - * @param Util $util |
|
38 | - */ |
|
39 | - public function __construct(Util $util) { |
|
40 | - parent::__construct(); |
|
41 | - $this->util = $util; |
|
42 | - } |
|
43 | - |
|
44 | - protected function configure() { |
|
45 | - parent::configure(); |
|
46 | - $this |
|
47 | - ->setName('encryption:show-key-storage-root') |
|
48 | - ->setDescription('Show current key storage root'); |
|
49 | - } |
|
50 | - |
|
51 | - protected function execute(InputInterface $input, OutputInterface $output) { |
|
52 | - $currentRoot = $this->util->getKeyStorageRoot(); |
|
53 | - |
|
54 | - $rootDescription = $currentRoot !== '' ? $currentRoot : 'default storage location (data/)'; |
|
55 | - |
|
56 | - $output->writeln("Current key storage root: <info>$rootDescription</info>"); |
|
57 | - } |
|
33 | + /** @var Util */ |
|
34 | + protected $util; |
|
35 | + |
|
36 | + /** |
|
37 | + * @param Util $util |
|
38 | + */ |
|
39 | + public function __construct(Util $util) { |
|
40 | + parent::__construct(); |
|
41 | + $this->util = $util; |
|
42 | + } |
|
43 | + |
|
44 | + protected function configure() { |
|
45 | + parent::configure(); |
|
46 | + $this |
|
47 | + ->setName('encryption:show-key-storage-root') |
|
48 | + ->setDescription('Show current key storage root'); |
|
49 | + } |
|
50 | + |
|
51 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
52 | + $currentRoot = $this->util->getKeyStorageRoot(); |
|
53 | + |
|
54 | + $rootDescription = $currentRoot !== '' ? $currentRoot : 'default storage location (data/)'; |
|
55 | + |
|
56 | + $output->writeln("Current key storage root: <info>$rootDescription</info>"); |
|
57 | + } |
|
58 | 58 | |
59 | 59 | } |
@@ -28,7 +28,7 @@ |
||
28 | 28 | use Symfony\Component\Console\Input\InputInterface; |
29 | 29 | use Symfony\Component\Console\Output\OutputInterface; |
30 | 30 | |
31 | -class ShowKeyStorageRoot extends Command{ |
|
31 | +class ShowKeyStorageRoot extends Command { |
|
32 | 32 | |
33 | 33 | /** @var Util */ |
34 | 34 | protected $util; |
@@ -29,51 +29,51 @@ |
||
29 | 29 | use Symfony\Component\Console\Output\OutputInterface; |
30 | 30 | |
31 | 31 | class Enable extends Command { |
32 | - /** @var IConfig */ |
|
33 | - protected $config; |
|
32 | + /** @var IConfig */ |
|
33 | + protected $config; |
|
34 | 34 | |
35 | - /** @var IManager */ |
|
36 | - protected $encryptionManager; |
|
35 | + /** @var IManager */ |
|
36 | + protected $encryptionManager; |
|
37 | 37 | |
38 | - /** |
|
39 | - * @param IConfig $config |
|
40 | - * @param IManager $encryptionManager |
|
41 | - */ |
|
42 | - public function __construct(IConfig $config, IManager $encryptionManager) { |
|
43 | - parent::__construct(); |
|
38 | + /** |
|
39 | + * @param IConfig $config |
|
40 | + * @param IManager $encryptionManager |
|
41 | + */ |
|
42 | + public function __construct(IConfig $config, IManager $encryptionManager) { |
|
43 | + parent::__construct(); |
|
44 | 44 | |
45 | - $this->encryptionManager = $encryptionManager; |
|
46 | - $this->config = $config; |
|
47 | - } |
|
45 | + $this->encryptionManager = $encryptionManager; |
|
46 | + $this->config = $config; |
|
47 | + } |
|
48 | 48 | |
49 | - protected function configure() { |
|
50 | - $this |
|
51 | - ->setName('encryption:enable') |
|
52 | - ->setDescription('Enable encryption') |
|
53 | - ; |
|
54 | - } |
|
49 | + protected function configure() { |
|
50 | + $this |
|
51 | + ->setName('encryption:enable') |
|
52 | + ->setDescription('Enable encryption') |
|
53 | + ; |
|
54 | + } |
|
55 | 55 | |
56 | - protected function execute(InputInterface $input, OutputInterface $output) { |
|
57 | - if ($this->config->getAppValue('core', 'encryption_enabled', 'no') === 'yes') { |
|
58 | - $output->writeln('Encryption is already enabled'); |
|
59 | - } else { |
|
60 | - $this->config->setAppValue('core', 'encryption_enabled', 'yes'); |
|
61 | - $output->writeln('<info>Encryption enabled</info>'); |
|
62 | - } |
|
63 | - $output->writeln(''); |
|
56 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
57 | + if ($this->config->getAppValue('core', 'encryption_enabled', 'no') === 'yes') { |
|
58 | + $output->writeln('Encryption is already enabled'); |
|
59 | + } else { |
|
60 | + $this->config->setAppValue('core', 'encryption_enabled', 'yes'); |
|
61 | + $output->writeln('<info>Encryption enabled</info>'); |
|
62 | + } |
|
63 | + $output->writeln(''); |
|
64 | 64 | |
65 | - $modules = $this->encryptionManager->getEncryptionModules(); |
|
66 | - if (empty($modules)) { |
|
67 | - $output->writeln('<error>No encryption module is loaded</error>'); |
|
68 | - } else { |
|
69 | - $defaultModule = $this->config->getAppValue('core', 'default_encryption_module', null); |
|
70 | - if ($defaultModule === null) { |
|
71 | - $output->writeln('<error>No default module is set</error>'); |
|
72 | - } else if (!isset($modules[$defaultModule])) { |
|
73 | - $output->writeln('<error>The current default module does not exist: ' . $defaultModule . '</error>'); |
|
74 | - } else { |
|
75 | - $output->writeln('Default module: ' . $defaultModule); |
|
76 | - } |
|
77 | - } |
|
78 | - } |
|
65 | + $modules = $this->encryptionManager->getEncryptionModules(); |
|
66 | + if (empty($modules)) { |
|
67 | + $output->writeln('<error>No encryption module is loaded</error>'); |
|
68 | + } else { |
|
69 | + $defaultModule = $this->config->getAppValue('core', 'default_encryption_module', null); |
|
70 | + if ($defaultModule === null) { |
|
71 | + $output->writeln('<error>No default module is set</error>'); |
|
72 | + } else if (!isset($modules[$defaultModule])) { |
|
73 | + $output->writeln('<error>The current default module does not exist: ' . $defaultModule . '</error>'); |
|
74 | + } else { |
|
75 | + $output->writeln('Default module: ' . $defaultModule); |
|
76 | + } |
|
77 | + } |
|
78 | + } |
|
79 | 79 | } |
@@ -70,9 +70,9 @@ |
||
70 | 70 | if ($defaultModule === null) { |
71 | 71 | $output->writeln('<error>No default module is set</error>'); |
72 | 72 | } else if (!isset($modules[$defaultModule])) { |
73 | - $output->writeln('<error>The current default module does not exist: ' . $defaultModule . '</error>'); |
|
73 | + $output->writeln('<error>The current default module does not exist: '.$defaultModule.'</error>'); |
|
74 | 74 | } else { |
75 | - $output->writeln('Default module: ' . $defaultModule); |
|
75 | + $output->writeln('Default module: '.$defaultModule); |
|
76 | 76 | } |
77 | 77 | } |
78 | 78 | } |
@@ -28,30 +28,30 @@ |
||
28 | 28 | use Symfony\Component\Console\Output\OutputInterface; |
29 | 29 | |
30 | 30 | class Disable extends Command { |
31 | - /** @var IConfig */ |
|
32 | - protected $config; |
|
31 | + /** @var IConfig */ |
|
32 | + protected $config; |
|
33 | 33 | |
34 | - /** |
|
35 | - * @param IConfig $config |
|
36 | - */ |
|
37 | - public function __construct(IConfig $config) { |
|
38 | - parent::__construct(); |
|
39 | - $this->config = $config; |
|
40 | - } |
|
34 | + /** |
|
35 | + * @param IConfig $config |
|
36 | + */ |
|
37 | + public function __construct(IConfig $config) { |
|
38 | + parent::__construct(); |
|
39 | + $this->config = $config; |
|
40 | + } |
|
41 | 41 | |
42 | - protected function configure() { |
|
43 | - $this |
|
44 | - ->setName('encryption:disable') |
|
45 | - ->setDescription('Disable encryption') |
|
46 | - ; |
|
47 | - } |
|
42 | + protected function configure() { |
|
43 | + $this |
|
44 | + ->setName('encryption:disable') |
|
45 | + ->setDescription('Disable encryption') |
|
46 | + ; |
|
47 | + } |
|
48 | 48 | |
49 | - protected function execute(InputInterface $input, OutputInterface $output) { |
|
50 | - if ($this->config->getAppValue('core', 'encryption_enabled', 'no') !== 'yes') { |
|
51 | - $output->writeln('Encryption is already disabled'); |
|
52 | - } else { |
|
53 | - $this->config->setAppValue('core', 'encryption_enabled', 'no'); |
|
54 | - $output->writeln('<info>Encryption disabled</info>'); |
|
55 | - } |
|
56 | - } |
|
49 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
50 | + if ($this->config->getAppValue('core', 'encryption_enabled', 'no') !== 'yes') { |
|
51 | + $output->writeln('Encryption is already disabled'); |
|
52 | + } else { |
|
53 | + $this->config->setAppValue('core', 'encryption_enabled', 'no'); |
|
54 | + $output->writeln('<info>Encryption disabled</info>'); |
|
55 | + } |
|
56 | + } |
|
57 | 57 | } |
@@ -71,7 +71,7 @@ |
||
71 | 71 | if (!$item['default']) { |
72 | 72 | $item = $item['displayName']; |
73 | 73 | } else { |
74 | - $item = $item['displayName'] . ' [default*]'; |
|
74 | + $item = $item['displayName'].' [default*]'; |
|
75 | 75 | } |
76 | 76 | }); |
77 | 77 | } |
@@ -29,69 +29,69 @@ |
||
29 | 29 | use Symfony\Component\Console\Output\OutputInterface; |
30 | 30 | |
31 | 31 | class ListModules extends Base { |
32 | - /** @var IManager */ |
|
33 | - protected $encryptionManager; |
|
32 | + /** @var IManager */ |
|
33 | + protected $encryptionManager; |
|
34 | 34 | |
35 | - /** @var IConfig */ |
|
36 | - protected $config; |
|
35 | + /** @var IConfig */ |
|
36 | + protected $config; |
|
37 | 37 | |
38 | - /** |
|
39 | - * @param IManager $encryptionManager |
|
40 | - * @param IConfig $config |
|
41 | - */ |
|
42 | - public function __construct( |
|
43 | - IManager $encryptionManager, |
|
44 | - IConfig $config |
|
45 | - ) { |
|
46 | - parent::__construct(); |
|
47 | - $this->encryptionManager = $encryptionManager; |
|
48 | - $this->config = $config; |
|
49 | - } |
|
38 | + /** |
|
39 | + * @param IManager $encryptionManager |
|
40 | + * @param IConfig $config |
|
41 | + */ |
|
42 | + public function __construct( |
|
43 | + IManager $encryptionManager, |
|
44 | + IConfig $config |
|
45 | + ) { |
|
46 | + parent::__construct(); |
|
47 | + $this->encryptionManager = $encryptionManager; |
|
48 | + $this->config = $config; |
|
49 | + } |
|
50 | 50 | |
51 | - protected function configure() { |
|
52 | - parent::configure(); |
|
51 | + protected function configure() { |
|
52 | + parent::configure(); |
|
53 | 53 | |
54 | - $this |
|
55 | - ->setName('encryption:list-modules') |
|
56 | - ->setDescription('List all available encryption modules') |
|
57 | - ; |
|
58 | - } |
|
54 | + $this |
|
55 | + ->setName('encryption:list-modules') |
|
56 | + ->setDescription('List all available encryption modules') |
|
57 | + ; |
|
58 | + } |
|
59 | 59 | |
60 | - protected function execute(InputInterface $input, OutputInterface $output) { |
|
61 | - $isMaintenanceModeEnabled = $this->config->getSystemValue('maintenance', false); |
|
62 | - if ($isMaintenanceModeEnabled) { |
|
63 | - $output->writeln("Maintenance mode must be disabled when listing modules"); |
|
64 | - $output->writeln("in order to list the relevant encryption modules correctly."); |
|
65 | - return; |
|
66 | - } |
|
60 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
61 | + $isMaintenanceModeEnabled = $this->config->getSystemValue('maintenance', false); |
|
62 | + if ($isMaintenanceModeEnabled) { |
|
63 | + $output->writeln("Maintenance mode must be disabled when listing modules"); |
|
64 | + $output->writeln("in order to list the relevant encryption modules correctly."); |
|
65 | + return; |
|
66 | + } |
|
67 | 67 | |
68 | - $encryptionModules = $this->encryptionManager->getEncryptionModules(); |
|
69 | - $defaultEncryptionModuleId = $this->encryptionManager->getDefaultEncryptionModuleId(); |
|
68 | + $encryptionModules = $this->encryptionManager->getEncryptionModules(); |
|
69 | + $defaultEncryptionModuleId = $this->encryptionManager->getDefaultEncryptionModuleId(); |
|
70 | 70 | |
71 | - $encModules = array(); |
|
72 | - foreach ($encryptionModules as $module) { |
|
73 | - $encModules[$module['id']]['displayName'] = $module['displayName']; |
|
74 | - $encModules[$module['id']]['default'] = $module['id'] === $defaultEncryptionModuleId; |
|
75 | - } |
|
76 | - $this->writeModuleList($input, $output, $encModules); |
|
77 | - } |
|
71 | + $encModules = array(); |
|
72 | + foreach ($encryptionModules as $module) { |
|
73 | + $encModules[$module['id']]['displayName'] = $module['displayName']; |
|
74 | + $encModules[$module['id']]['default'] = $module['id'] === $defaultEncryptionModuleId; |
|
75 | + } |
|
76 | + $this->writeModuleList($input, $output, $encModules); |
|
77 | + } |
|
78 | 78 | |
79 | - /** |
|
80 | - * @param InputInterface $input |
|
81 | - * @param OutputInterface $output |
|
82 | - * @param array $items |
|
83 | - */ |
|
84 | - protected function writeModuleList(InputInterface $input, OutputInterface $output, $items) { |
|
85 | - if ($input->getOption('output') === self::OUTPUT_FORMAT_PLAIN) { |
|
86 | - array_walk($items, function(&$item) { |
|
87 | - if (!$item['default']) { |
|
88 | - $item = $item['displayName']; |
|
89 | - } else { |
|
90 | - $item = $item['displayName'] . ' [default*]'; |
|
91 | - } |
|
92 | - }); |
|
93 | - } |
|
79 | + /** |
|
80 | + * @param InputInterface $input |
|
81 | + * @param OutputInterface $output |
|
82 | + * @param array $items |
|
83 | + */ |
|
84 | + protected function writeModuleList(InputInterface $input, OutputInterface $output, $items) { |
|
85 | + if ($input->getOption('output') === self::OUTPUT_FORMAT_PLAIN) { |
|
86 | + array_walk($items, function(&$item) { |
|
87 | + if (!$item['default']) { |
|
88 | + $item = $item['displayName']; |
|
89 | + } else { |
|
90 | + $item = $item['displayName'] . ' [default*]'; |
|
91 | + } |
|
92 | + }); |
|
93 | + } |
|
94 | 94 | |
95 | - $this->writeArrayInOutputFormat($input, $output, $items); |
|
96 | - } |
|
95 | + $this->writeArrayInOutputFormat($input, $output, $items); |
|
96 | + } |
|
97 | 97 | } |
@@ -28,30 +28,30 @@ |
||
28 | 28 | use Symfony\Component\Console\Output\OutputInterface; |
29 | 29 | |
30 | 30 | class Status extends Base { |
31 | - /** @var IManager */ |
|
32 | - protected $encryptionManager; |
|
31 | + /** @var IManager */ |
|
32 | + protected $encryptionManager; |
|
33 | 33 | |
34 | - /** |
|
35 | - * @param IManager $encryptionManager |
|
36 | - */ |
|
37 | - public function __construct(IManager $encryptionManager) { |
|
38 | - parent::__construct(); |
|
39 | - $this->encryptionManager = $encryptionManager; |
|
40 | - } |
|
34 | + /** |
|
35 | + * @param IManager $encryptionManager |
|
36 | + */ |
|
37 | + public function __construct(IManager $encryptionManager) { |
|
38 | + parent::__construct(); |
|
39 | + $this->encryptionManager = $encryptionManager; |
|
40 | + } |
|
41 | 41 | |
42 | - protected function configure() { |
|
43 | - parent::configure(); |
|
42 | + protected function configure() { |
|
43 | + parent::configure(); |
|
44 | 44 | |
45 | - $this |
|
46 | - ->setName('encryption:status') |
|
47 | - ->setDescription('Lists the current status of encryption') |
|
48 | - ; |
|
49 | - } |
|
45 | + $this |
|
46 | + ->setName('encryption:status') |
|
47 | + ->setDescription('Lists the current status of encryption') |
|
48 | + ; |
|
49 | + } |
|
50 | 50 | |
51 | - protected function execute(InputInterface $input, OutputInterface $output) { |
|
52 | - $this->writeArrayInOutputFormat($input, $output, [ |
|
53 | - 'enabled' => $this->encryptionManager->isEnabled(), |
|
54 | - 'defaultModule' => $this->encryptionManager->getDefaultEncryptionModuleId(), |
|
55 | - ]); |
|
56 | - } |
|
51 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
52 | + $this->writeArrayInOutputFormat($input, $output, [ |
|
53 | + 'enabled' => $this->encryptionManager->isEnabled(), |
|
54 | + 'defaultModule' => $this->encryptionManager->getDefaultEncryptionModuleId(), |
|
55 | + ]); |
|
56 | + } |
|
57 | 57 | } |
@@ -59,11 +59,11 @@ |
||
59 | 59 | $moduleId = $input->getArgument('module'); |
60 | 60 | |
61 | 61 | if ($moduleId === $this->encryptionManager->getDefaultEncryptionModuleId()) { |
62 | - $output->writeln('"' . $moduleId . '"" is already the default module'); |
|
62 | + $output->writeln('"'.$moduleId.'"" is already the default module'); |
|
63 | 63 | } else if ($this->encryptionManager->setDefaultEncryptionModule($moduleId)) { |
64 | - $output->writeln('<info>Set default module to "' . $moduleId . '"</info>'); |
|
64 | + $output->writeln('<info>Set default module to "'.$moduleId.'"</info>'); |
|
65 | 65 | } else { |
66 | - $output->writeln('<error>The specified module "' . $moduleId . '" does not exist</error>'); |
|
66 | + $output->writeln('<error>The specified module "'.$moduleId.'" does not exist</error>'); |
|
67 | 67 | } |
68 | 68 | } |
69 | 69 | } |
@@ -31,55 +31,55 @@ |
||
31 | 31 | use Symfony\Component\Console\Output\OutputInterface; |
32 | 32 | |
33 | 33 | class SetDefaultModule extends Command { |
34 | - /** @var IManager */ |
|
35 | - protected $encryptionManager; |
|
34 | + /** @var IManager */ |
|
35 | + protected $encryptionManager; |
|
36 | 36 | |
37 | - /** @var IConfig */ |
|
38 | - protected $config; |
|
37 | + /** @var IConfig */ |
|
38 | + protected $config; |
|
39 | 39 | |
40 | - /** |
|
41 | - * @param IManager $encryptionManager |
|
42 | - * @param IConfig $config |
|
43 | - */ |
|
44 | - public function __construct( |
|
45 | - IManager $encryptionManager, |
|
46 | - IConfig $config |
|
47 | - ) { |
|
48 | - parent::__construct(); |
|
49 | - $this->encryptionManager = $encryptionManager; |
|
50 | - $this->config = $config; |
|
51 | - } |
|
40 | + /** |
|
41 | + * @param IManager $encryptionManager |
|
42 | + * @param IConfig $config |
|
43 | + */ |
|
44 | + public function __construct( |
|
45 | + IManager $encryptionManager, |
|
46 | + IConfig $config |
|
47 | + ) { |
|
48 | + parent::__construct(); |
|
49 | + $this->encryptionManager = $encryptionManager; |
|
50 | + $this->config = $config; |
|
51 | + } |
|
52 | 52 | |
53 | - protected function configure() { |
|
54 | - parent::configure(); |
|
53 | + protected function configure() { |
|
54 | + parent::configure(); |
|
55 | 55 | |
56 | - $this |
|
57 | - ->setName('encryption:set-default-module') |
|
58 | - ->setDescription('Set the encryption default module') |
|
59 | - ->addArgument( |
|
60 | - 'module', |
|
61 | - InputArgument::REQUIRED, |
|
62 | - 'ID of the encryption module that should be used' |
|
63 | - ) |
|
64 | - ; |
|
65 | - } |
|
56 | + $this |
|
57 | + ->setName('encryption:set-default-module') |
|
58 | + ->setDescription('Set the encryption default module') |
|
59 | + ->addArgument( |
|
60 | + 'module', |
|
61 | + InputArgument::REQUIRED, |
|
62 | + 'ID of the encryption module that should be used' |
|
63 | + ) |
|
64 | + ; |
|
65 | + } |
|
66 | 66 | |
67 | - protected function execute(InputInterface $input, OutputInterface $output) { |
|
68 | - $isMaintenanceModeEnabled = $this->config->getSystemValue('maintenance', false); |
|
69 | - if ($isMaintenanceModeEnabled) { |
|
70 | - $output->writeln("Maintenance mode must be disabled when setting default module,"); |
|
71 | - $output->writeln("in order to load the relevant encryption modules correctly."); |
|
72 | - return; |
|
73 | - } |
|
67 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
68 | + $isMaintenanceModeEnabled = $this->config->getSystemValue('maintenance', false); |
|
69 | + if ($isMaintenanceModeEnabled) { |
|
70 | + $output->writeln("Maintenance mode must be disabled when setting default module,"); |
|
71 | + $output->writeln("in order to load the relevant encryption modules correctly."); |
|
72 | + return; |
|
73 | + } |
|
74 | 74 | |
75 | - $moduleId = $input->getArgument('module'); |
|
75 | + $moduleId = $input->getArgument('module'); |
|
76 | 76 | |
77 | - if ($moduleId === $this->encryptionManager->getDefaultEncryptionModuleId()) { |
|
78 | - $output->writeln('"' . $moduleId . '"" is already the default module'); |
|
79 | - } else if ($this->encryptionManager->setDefaultEncryptionModule($moduleId)) { |
|
80 | - $output->writeln('<info>Set default module to "' . $moduleId . '"</info>'); |
|
81 | - } else { |
|
82 | - $output->writeln('<error>The specified module "' . $moduleId . '" does not exist</error>'); |
|
83 | - } |
|
84 | - } |
|
77 | + if ($moduleId === $this->encryptionManager->getDefaultEncryptionModuleId()) { |
|
78 | + $output->writeln('"' . $moduleId . '"" is already the default module'); |
|
79 | + } else if ($this->encryptionManager->setDefaultEncryptionModule($moduleId)) { |
|
80 | + $output->writeln('<info>Set default module to "' . $moduleId . '"</info>'); |
|
81 | + } else { |
|
82 | + $output->writeln('<error>The specified module "' . $moduleId . '" does not exist</error>'); |
|
83 | + } |
|
84 | + } |
|
85 | 85 | } |
@@ -34,58 +34,58 @@ |
||
34 | 34 | use Symfony\Component\Console\Output\OutputInterface; |
35 | 35 | |
36 | 36 | class ListCommand extends Base { |
37 | - /** @var IGroupManager */ |
|
38 | - protected $groupManager; |
|
37 | + /** @var IGroupManager */ |
|
38 | + protected $groupManager; |
|
39 | 39 | |
40 | - /** |
|
41 | - * @param IGroupManager $groupManager |
|
42 | - */ |
|
43 | - public function __construct(IGroupManager $groupManager) { |
|
44 | - $this->groupManager = $groupManager; |
|
45 | - parent::__construct(); |
|
46 | - } |
|
40 | + /** |
|
41 | + * @param IGroupManager $groupManager |
|
42 | + */ |
|
43 | + public function __construct(IGroupManager $groupManager) { |
|
44 | + $this->groupManager = $groupManager; |
|
45 | + parent::__construct(); |
|
46 | + } |
|
47 | 47 | |
48 | - protected function configure() { |
|
49 | - $this |
|
50 | - ->setName('group:list') |
|
51 | - ->setDescription('list configured groups') |
|
52 | - ->addOption( |
|
53 | - 'limit', |
|
54 | - 'l', |
|
55 | - InputOption::VALUE_OPTIONAL, |
|
56 | - 'Number of groups to retrieve', |
|
57 | - 500 |
|
58 | - )->addOption( |
|
59 | - 'offset', |
|
60 | - 'o', |
|
61 | - InputOption::VALUE_OPTIONAL, |
|
62 | - 'Offset for retrieving groups', |
|
63 | - 0 |
|
64 | - )->addOption( |
|
65 | - 'output', |
|
66 | - null, |
|
67 | - InputOption::VALUE_OPTIONAL, |
|
68 | - 'Output format (plain, json or json_pretty, default is plain)', |
|
69 | - $this->defaultOutputFormat |
|
70 | - ); |
|
71 | - } |
|
48 | + protected function configure() { |
|
49 | + $this |
|
50 | + ->setName('group:list') |
|
51 | + ->setDescription('list configured groups') |
|
52 | + ->addOption( |
|
53 | + 'limit', |
|
54 | + 'l', |
|
55 | + InputOption::VALUE_OPTIONAL, |
|
56 | + 'Number of groups to retrieve', |
|
57 | + 500 |
|
58 | + )->addOption( |
|
59 | + 'offset', |
|
60 | + 'o', |
|
61 | + InputOption::VALUE_OPTIONAL, |
|
62 | + 'Offset for retrieving groups', |
|
63 | + 0 |
|
64 | + )->addOption( |
|
65 | + 'output', |
|
66 | + null, |
|
67 | + InputOption::VALUE_OPTIONAL, |
|
68 | + 'Output format (plain, json or json_pretty, default is plain)', |
|
69 | + $this->defaultOutputFormat |
|
70 | + ); |
|
71 | + } |
|
72 | 72 | |
73 | - protected function execute(InputInterface $input, OutputInterface $output) { |
|
74 | - $groups = $this->groupManager->search('', (int)$input->getOption('limit'), (int)$input->getOption('offset')); |
|
75 | - $this->writeArrayInOutputFormat($input, $output, $this->formatGroups($groups)); |
|
76 | - } |
|
73 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
74 | + $groups = $this->groupManager->search('', (int)$input->getOption('limit'), (int)$input->getOption('offset')); |
|
75 | + $this->writeArrayInOutputFormat($input, $output, $this->formatGroups($groups)); |
|
76 | + } |
|
77 | 77 | |
78 | - /** |
|
79 | - * @param IGroup[] $groups |
|
80 | - * @return array |
|
81 | - */ |
|
82 | - private function formatGroups(array $groups) { |
|
83 | - $keys = array_map(function (IGroup $group) { |
|
84 | - return $group->getGID(); |
|
85 | - }, $groups); |
|
86 | - $values = array_map(function (IGroup $group) { |
|
87 | - return array_keys($group->getUsers()); |
|
88 | - }, $groups); |
|
89 | - return array_combine($keys, $values); |
|
90 | - } |
|
78 | + /** |
|
79 | + * @param IGroup[] $groups |
|
80 | + * @return array |
|
81 | + */ |
|
82 | + private function formatGroups(array $groups) { |
|
83 | + $keys = array_map(function (IGroup $group) { |
|
84 | + return $group->getGID(); |
|
85 | + }, $groups); |
|
86 | + $values = array_map(function (IGroup $group) { |
|
87 | + return array_keys($group->getUsers()); |
|
88 | + }, $groups); |
|
89 | + return array_combine($keys, $values); |
|
90 | + } |
|
91 | 91 | } |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | } |
72 | 72 | |
73 | 73 | protected function execute(InputInterface $input, OutputInterface $output) { |
74 | - $groups = $this->groupManager->search('', (int)$input->getOption('limit'), (int)$input->getOption('offset')); |
|
74 | + $groups = $this->groupManager->search('', (int) $input->getOption('limit'), (int) $input->getOption('offset')); |
|
75 | 75 | $this->writeArrayInOutputFormat($input, $output, $this->formatGroups($groups)); |
76 | 76 | } |
77 | 77 | |
@@ -80,10 +80,10 @@ discard block |
||
80 | 80 | * @return array |
81 | 81 | */ |
82 | 82 | private function formatGroups(array $groups) { |
83 | - $keys = array_map(function (IGroup $group) { |
|
83 | + $keys = array_map(function(IGroup $group) { |
|
84 | 84 | return $group->getGID(); |
85 | 85 | }, $groups); |
86 | - $values = array_map(function (IGroup $group) { |
|
86 | + $values = array_map(function(IGroup $group) { |
|
87 | 87 | return array_keys($group->getUsers()); |
88 | 88 | }, $groups); |
89 | 89 | return array_combine($keys, $values); |
@@ -33,47 +33,47 @@ |
||
33 | 33 | use Symfony\Component\Console\Output\OutputInterface; |
34 | 34 | |
35 | 35 | class RemoveUser extends Base { |
36 | - /** @var IUserManager */ |
|
37 | - protected $userManager; |
|
38 | - /** @var IGroupManager */ |
|
39 | - protected $groupManager; |
|
36 | + /** @var IUserManager */ |
|
37 | + protected $userManager; |
|
38 | + /** @var IGroupManager */ |
|
39 | + protected $groupManager; |
|
40 | 40 | |
41 | - /** |
|
42 | - * @param IUserManager $userManager |
|
43 | - * @param IGroupManager $groupManager |
|
44 | - */ |
|
45 | - public function __construct(IUserManager $userManager, IGroupManager $groupManager) { |
|
46 | - $this->userManager = $userManager; |
|
47 | - $this->groupManager = $groupManager; |
|
48 | - parent::__construct(); |
|
49 | - } |
|
41 | + /** |
|
42 | + * @param IUserManager $userManager |
|
43 | + * @param IGroupManager $groupManager |
|
44 | + */ |
|
45 | + public function __construct(IUserManager $userManager, IGroupManager $groupManager) { |
|
46 | + $this->userManager = $userManager; |
|
47 | + $this->groupManager = $groupManager; |
|
48 | + parent::__construct(); |
|
49 | + } |
|
50 | 50 | |
51 | - protected function configure() { |
|
52 | - $this |
|
53 | - ->setName('group:removeuser') |
|
54 | - ->setDescription('remove a user from a group') |
|
55 | - ->addArgument( |
|
56 | - 'group', |
|
57 | - InputArgument::REQUIRED, |
|
58 | - 'group to remove the user from' |
|
59 | - )->addArgument( |
|
60 | - 'user', |
|
61 | - InputArgument::REQUIRED, |
|
62 | - 'user to remove from the group' |
|
63 | - ); |
|
64 | - } |
|
51 | + protected function configure() { |
|
52 | + $this |
|
53 | + ->setName('group:removeuser') |
|
54 | + ->setDescription('remove a user from a group') |
|
55 | + ->addArgument( |
|
56 | + 'group', |
|
57 | + InputArgument::REQUIRED, |
|
58 | + 'group to remove the user from' |
|
59 | + )->addArgument( |
|
60 | + 'user', |
|
61 | + InputArgument::REQUIRED, |
|
62 | + 'user to remove from the group' |
|
63 | + ); |
|
64 | + } |
|
65 | 65 | |
66 | - protected function execute(InputInterface $input, OutputInterface $output) { |
|
67 | - $group = $this->groupManager->get($input->getArgument('group')); |
|
68 | - if (is_null($group)) { |
|
69 | - $output->writeln('<error>group not found</error>'); |
|
70 | - return 1; |
|
71 | - } |
|
72 | - $user = $this->userManager->get($input->getArgument('user')); |
|
73 | - if (is_null($user)) { |
|
74 | - $output->writeln('<error>user not found</error>'); |
|
75 | - return 1; |
|
76 | - } |
|
77 | - $group->removeUser($user); |
|
78 | - } |
|
66 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
67 | + $group = $this->groupManager->get($input->getArgument('group')); |
|
68 | + if (is_null($group)) { |
|
69 | + $output->writeln('<error>group not found</error>'); |
|
70 | + return 1; |
|
71 | + } |
|
72 | + $user = $this->userManager->get($input->getArgument('user')); |
|
73 | + if (is_null($user)) { |
|
74 | + $output->writeln('<error>user not found</error>'); |
|
75 | + return 1; |
|
76 | + } |
|
77 | + $group->removeUser($user); |
|
78 | + } |
|
79 | 79 | } |