@@ -32,45 +32,45 @@ |
||
| 32 | 32 | |
| 33 | 33 | class Mode extends Command { |
| 34 | 34 | |
| 35 | - /** @var IConfig */ |
|
| 36 | - protected $config; |
|
| 35 | + /** @var IConfig */ |
|
| 36 | + protected $config; |
|
| 37 | 37 | |
| 38 | - public function __construct(IConfig $config) { |
|
| 39 | - $this->config = $config; |
|
| 40 | - parent::__construct(); |
|
| 41 | - } |
|
| 38 | + public function __construct(IConfig $config) { |
|
| 39 | + $this->config = $config; |
|
| 40 | + parent::__construct(); |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - protected function configure() { |
|
| 44 | - $this |
|
| 45 | - ->setName('maintenance:mode') |
|
| 46 | - ->setDescription('set maintenance mode') |
|
| 47 | - ->addOption( |
|
| 48 | - 'on', |
|
| 49 | - null, |
|
| 50 | - InputOption::VALUE_NONE, |
|
| 51 | - 'enable maintenance mode' |
|
| 52 | - ) |
|
| 53 | - ->addOption( |
|
| 54 | - 'off', |
|
| 55 | - null, |
|
| 56 | - InputOption::VALUE_NONE, |
|
| 57 | - 'disable maintenance mode' |
|
| 58 | - ); |
|
| 59 | - } |
|
| 43 | + protected function configure() { |
|
| 44 | + $this |
|
| 45 | + ->setName('maintenance:mode') |
|
| 46 | + ->setDescription('set maintenance mode') |
|
| 47 | + ->addOption( |
|
| 48 | + 'on', |
|
| 49 | + null, |
|
| 50 | + InputOption::VALUE_NONE, |
|
| 51 | + 'enable maintenance mode' |
|
| 52 | + ) |
|
| 53 | + ->addOption( |
|
| 54 | + 'off', |
|
| 55 | + null, |
|
| 56 | + InputOption::VALUE_NONE, |
|
| 57 | + 'disable maintenance mode' |
|
| 58 | + ); |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - protected function execute(InputInterface $input, OutputInterface $output) { |
|
| 62 | - if ($input->getOption('on')) { |
|
| 63 | - $this->config->setSystemValue('maintenance', true); |
|
| 64 | - $output->writeln('Maintenance mode enabled'); |
|
| 65 | - } elseif ($input->getOption('off')) { |
|
| 66 | - $this->config->setSystemValue('maintenance', false); |
|
| 67 | - $output->writeln('Maintenance mode disabled'); |
|
| 68 | - } else { |
|
| 69 | - if ($this->config->getSystemValue('maintenance', false)) { |
|
| 70 | - $output->writeln('Maintenance mode is currently enabled'); |
|
| 71 | - } else { |
|
| 72 | - $output->writeln('Maintenance mode is currently disabled'); |
|
| 73 | - } |
|
| 74 | - } |
|
| 75 | - } |
|
| 61 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
| 62 | + if ($input->getOption('on')) { |
|
| 63 | + $this->config->setSystemValue('maintenance', true); |
|
| 64 | + $output->writeln('Maintenance mode enabled'); |
|
| 65 | + } elseif ($input->getOption('off')) { |
|
| 66 | + $this->config->setSystemValue('maintenance', false); |
|
| 67 | + $output->writeln('Maintenance mode disabled'); |
|
| 68 | + } else { |
|
| 69 | + if ($this->config->getSystemValue('maintenance', false)) { |
|
| 70 | + $output->writeln('Maintenance mode is currently enabled'); |
|
| 71 | + } else { |
|
| 72 | + $output->writeln('Maintenance mode is currently disabled'); |
|
| 73 | + } |
|
| 74 | + } |
|
| 75 | + } |
|
| 76 | 76 | } |
@@ -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 | } |
@@ -37,79 +37,79 @@ |
||
| 37 | 37 | |
| 38 | 38 | class Enable extends Command implements CompletionAwareInterface { |
| 39 | 39 | |
| 40 | - /** @var IAppManager */ |
|
| 41 | - protected $manager; |
|
| 40 | + /** @var IAppManager */ |
|
| 41 | + protected $manager; |
|
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * @param IAppManager $manager |
|
| 45 | - */ |
|
| 46 | - public function __construct(IAppManager $manager) { |
|
| 47 | - parent::__construct(); |
|
| 48 | - $this->manager = $manager; |
|
| 49 | - } |
|
| 43 | + /** |
|
| 44 | + * @param IAppManager $manager |
|
| 45 | + */ |
|
| 46 | + public function __construct(IAppManager $manager) { |
|
| 47 | + parent::__construct(); |
|
| 48 | + $this->manager = $manager; |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - protected function configure() { |
|
| 52 | - $this |
|
| 53 | - ->setName('app:enable') |
|
| 54 | - ->setDescription('enable an app') |
|
| 55 | - ->addArgument( |
|
| 56 | - 'app-id', |
|
| 57 | - InputArgument::REQUIRED, |
|
| 58 | - 'enable the specified app' |
|
| 59 | - ) |
|
| 60 | - ->addOption( |
|
| 61 | - 'groups', |
|
| 62 | - 'g', |
|
| 63 | - InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, |
|
| 64 | - 'enable the app only for a list of groups' |
|
| 65 | - ) |
|
| 66 | - ; |
|
| 67 | - } |
|
| 51 | + protected function configure() { |
|
| 52 | + $this |
|
| 53 | + ->setName('app:enable') |
|
| 54 | + ->setDescription('enable an app') |
|
| 55 | + ->addArgument( |
|
| 56 | + 'app-id', |
|
| 57 | + InputArgument::REQUIRED, |
|
| 58 | + 'enable the specified app' |
|
| 59 | + ) |
|
| 60 | + ->addOption( |
|
| 61 | + 'groups', |
|
| 62 | + 'g', |
|
| 63 | + InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, |
|
| 64 | + 'enable the app only for a list of groups' |
|
| 65 | + ) |
|
| 66 | + ; |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | - protected function execute(InputInterface $input, OutputInterface $output) { |
|
| 70 | - $appId = $input->getArgument('app-id'); |
|
| 69 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
| 70 | + $appId = $input->getArgument('app-id'); |
|
| 71 | 71 | |
| 72 | - if (!\OC_App::getAppPath($appId)) { |
|
| 73 | - $output->writeln($appId . ' not found'); |
|
| 74 | - return 1; |
|
| 75 | - } |
|
| 72 | + if (!\OC_App::getAppPath($appId)) { |
|
| 73 | + $output->writeln($appId . ' not found'); |
|
| 74 | + return 1; |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - $groups = $input->getOption('groups'); |
|
| 78 | - $appClass = new \OC_App(); |
|
| 79 | - if (empty($groups)) { |
|
| 80 | - $appClass->enable($appId); |
|
| 81 | - $output->writeln($appId . ' enabled'); |
|
| 82 | - } else { |
|
| 83 | - $appClass->enable($appId, $groups); |
|
| 84 | - $output->writeln($appId . ' enabled for groups: ' . implode(', ', $groups)); |
|
| 85 | - } |
|
| 86 | - return 0; |
|
| 87 | - } |
|
| 77 | + $groups = $input->getOption('groups'); |
|
| 78 | + $appClass = new \OC_App(); |
|
| 79 | + if (empty($groups)) { |
|
| 80 | + $appClass->enable($appId); |
|
| 81 | + $output->writeln($appId . ' enabled'); |
|
| 82 | + } else { |
|
| 83 | + $appClass->enable($appId, $groups); |
|
| 84 | + $output->writeln($appId . ' enabled for groups: ' . implode(', ', $groups)); |
|
| 85 | + } |
|
| 86 | + return 0; |
|
| 87 | + } |
|
| 88 | 88 | |
| 89 | - /** |
|
| 90 | - * @param string $optionName |
|
| 91 | - * @param CompletionContext $context |
|
| 92 | - * @return string[] |
|
| 93 | - */ |
|
| 94 | - public function completeOptionValues($optionName, CompletionContext $context) { |
|
| 95 | - if ($optionName === 'groups') { |
|
| 96 | - return array_map(function(IGroup $group) { |
|
| 97 | - return $group->getGID(); |
|
| 98 | - }, \OC::$server->getGroupManager()->search($context->getCurrentWord())); |
|
| 99 | - } |
|
| 100 | - return []; |
|
| 101 | - } |
|
| 89 | + /** |
|
| 90 | + * @param string $optionName |
|
| 91 | + * @param CompletionContext $context |
|
| 92 | + * @return string[] |
|
| 93 | + */ |
|
| 94 | + public function completeOptionValues($optionName, CompletionContext $context) { |
|
| 95 | + if ($optionName === 'groups') { |
|
| 96 | + return array_map(function(IGroup $group) { |
|
| 97 | + return $group->getGID(); |
|
| 98 | + }, \OC::$server->getGroupManager()->search($context->getCurrentWord())); |
|
| 99 | + } |
|
| 100 | + return []; |
|
| 101 | + } |
|
| 102 | 102 | |
| 103 | - /** |
|
| 104 | - * @param string $argumentName |
|
| 105 | - * @param CompletionContext $context |
|
| 106 | - * @return string[] |
|
| 107 | - */ |
|
| 108 | - public function completeArgumentValues($argumentName, CompletionContext $context) { |
|
| 109 | - if ($argumentName === 'app-id') { |
|
| 110 | - $allApps = \OC_App::getAllApps(); |
|
| 111 | - return array_diff($allApps, \OC_App::getEnabledApps(true, true)); |
|
| 112 | - } |
|
| 113 | - return []; |
|
| 114 | - } |
|
| 103 | + /** |
|
| 104 | + * @param string $argumentName |
|
| 105 | + * @param CompletionContext $context |
|
| 106 | + * @return string[] |
|
| 107 | + */ |
|
| 108 | + public function completeArgumentValues($argumentName, CompletionContext $context) { |
|
| 109 | + if ($argumentName === 'app-id') { |
|
| 110 | + $allApps = \OC_App::getAllApps(); |
|
| 111 | + return array_diff($allApps, \OC_App::getEnabledApps(true, true)); |
|
| 112 | + } |
|
| 113 | + return []; |
|
| 114 | + } |
|
| 115 | 115 | } |
@@ -35,61 +35,61 @@ |
||
| 35 | 35 | |
| 36 | 36 | class Disable extends Command implements CompletionAwareInterface { |
| 37 | 37 | |
| 38 | - /** @var IAppManager */ |
|
| 39 | - protected $manager; |
|
| 38 | + /** @var IAppManager */ |
|
| 39 | + protected $manager; |
|
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * @param IAppManager $manager |
|
| 43 | - */ |
|
| 44 | - public function __construct(IAppManager $manager) { |
|
| 45 | - parent::__construct(); |
|
| 46 | - $this->manager = $manager; |
|
| 47 | - } |
|
| 41 | + /** |
|
| 42 | + * @param IAppManager $manager |
|
| 43 | + */ |
|
| 44 | + public function __construct(IAppManager $manager) { |
|
| 45 | + parent::__construct(); |
|
| 46 | + $this->manager = $manager; |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - protected function configure() { |
|
| 50 | - $this |
|
| 51 | - ->setName('app:disable') |
|
| 52 | - ->setDescription('disable an app') |
|
| 53 | - ->addArgument( |
|
| 54 | - 'app-id', |
|
| 55 | - InputArgument::REQUIRED, |
|
| 56 | - 'disable the specified app' |
|
| 57 | - ); |
|
| 58 | - } |
|
| 49 | + protected function configure() { |
|
| 50 | + $this |
|
| 51 | + ->setName('app:disable') |
|
| 52 | + ->setDescription('disable an app') |
|
| 53 | + ->addArgument( |
|
| 54 | + 'app-id', |
|
| 55 | + InputArgument::REQUIRED, |
|
| 56 | + 'disable the specified app' |
|
| 57 | + ); |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | - protected function execute(InputInterface $input, OutputInterface $output) { |
|
| 61 | - $appId = $input->getArgument('app-id'); |
|
| 62 | - if ($this->manager->isInstalled($appId)) { |
|
| 63 | - try { |
|
| 64 | - $this->manager->disableApp($appId); |
|
| 65 | - $output->writeln($appId . ' disabled'); |
|
| 66 | - } catch(\Exception $e) { |
|
| 67 | - $output->writeln($e->getMessage()); |
|
| 68 | - return 2; |
|
| 69 | - } |
|
| 70 | - } else { |
|
| 71 | - $output->writeln('No such app enabled: ' . $appId); |
|
| 72 | - } |
|
| 73 | - } |
|
| 60 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
| 61 | + $appId = $input->getArgument('app-id'); |
|
| 62 | + if ($this->manager->isInstalled($appId)) { |
|
| 63 | + try { |
|
| 64 | + $this->manager->disableApp($appId); |
|
| 65 | + $output->writeln($appId . ' disabled'); |
|
| 66 | + } catch(\Exception $e) { |
|
| 67 | + $output->writeln($e->getMessage()); |
|
| 68 | + return 2; |
|
| 69 | + } |
|
| 70 | + } else { |
|
| 71 | + $output->writeln('No such app enabled: ' . $appId); |
|
| 72 | + } |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | - /** |
|
| 76 | - * @param string $optionName |
|
| 77 | - * @param CompletionContext $context |
|
| 78 | - * @return string[] |
|
| 79 | - */ |
|
| 80 | - public function completeOptionValues($optionName, CompletionContext $context) { |
|
| 81 | - return []; |
|
| 82 | - } |
|
| 75 | + /** |
|
| 76 | + * @param string $optionName |
|
| 77 | + * @param CompletionContext $context |
|
| 78 | + * @return string[] |
|
| 79 | + */ |
|
| 80 | + public function completeOptionValues($optionName, CompletionContext $context) { |
|
| 81 | + return []; |
|
| 82 | + } |
|
| 83 | 83 | |
| 84 | - /** |
|
| 85 | - * @param string $argumentName |
|
| 86 | - * @param CompletionContext $context |
|
| 87 | - * @return string[] |
|
| 88 | - */ |
|
| 89 | - public function completeArgumentValues($argumentName, CompletionContext $context) { |
|
| 90 | - if ($argumentName === 'app-id') { |
|
| 91 | - return array_diff(\OC_App::getEnabledApps(true, true), $this->manager->getAlwaysEnabledApps()); |
|
| 92 | - } |
|
| 93 | - return []; |
|
| 94 | - } |
|
| 84 | + /** |
|
| 85 | + * @param string $argumentName |
|
| 86 | + * @param CompletionContext $context |
|
| 87 | + * @return string[] |
|
| 88 | + */ |
|
| 89 | + public function completeArgumentValues($argumentName, CompletionContext $context) { |
|
| 90 | + if ($argumentName === 'app-id') { |
|
| 91 | + return array_diff(\OC_App::getEnabledApps(true, true), $this->manager->getAlwaysEnabledApps()); |
|
| 92 | + } |
|
| 93 | + return []; |
|
| 94 | + } |
|
| 95 | 95 | } |
@@ -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 | } |
@@ -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 | } |
@@ -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 | } |
@@ -28,54 +28,54 @@ |
||
| 28 | 28 | use Symfony\Component\Console\Output\OutputInterface; |
| 29 | 29 | |
| 30 | 30 | class ListModules 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:list-modules') |
|
| 47 | - ->setDescription('List all available encryption modules') |
|
| 48 | - ; |
|
| 49 | - } |
|
| 45 | + $this |
|
| 46 | + ->setName('encryption:list-modules') |
|
| 47 | + ->setDescription('List all available encryption modules') |
|
| 48 | + ; |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - protected function execute(InputInterface $input, OutputInterface $output) { |
|
| 52 | - $encryptionModules = $this->encryptionManager->getEncryptionModules(); |
|
| 53 | - $defaultEncryptionModuleId = $this->encryptionManager->getDefaultEncryptionModuleId(); |
|
| 51 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
| 52 | + $encryptionModules = $this->encryptionManager->getEncryptionModules(); |
|
| 53 | + $defaultEncryptionModuleId = $this->encryptionManager->getDefaultEncryptionModuleId(); |
|
| 54 | 54 | |
| 55 | - $encModules = array(); |
|
| 56 | - foreach ($encryptionModules as $module) { |
|
| 57 | - $encModules[$module['id']]['displayName'] = $module['displayName']; |
|
| 58 | - $encModules[$module['id']]['default'] = $module['id'] === $defaultEncryptionModuleId; |
|
| 59 | - } |
|
| 60 | - $this->writeModuleList($input, $output, $encModules); |
|
| 61 | - } |
|
| 55 | + $encModules = array(); |
|
| 56 | + foreach ($encryptionModules as $module) { |
|
| 57 | + $encModules[$module['id']]['displayName'] = $module['displayName']; |
|
| 58 | + $encModules[$module['id']]['default'] = $module['id'] === $defaultEncryptionModuleId; |
|
| 59 | + } |
|
| 60 | + $this->writeModuleList($input, $output, $encModules); |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - /** |
|
| 64 | - * @param InputInterface $input |
|
| 65 | - * @param OutputInterface $output |
|
| 66 | - * @param array $items |
|
| 67 | - */ |
|
| 68 | - protected function writeModuleList(InputInterface $input, OutputInterface $output, $items) { |
|
| 69 | - if ($input->getOption('output') === self::OUTPUT_FORMAT_PLAIN) { |
|
| 70 | - array_walk($items, function(&$item) { |
|
| 71 | - if (!$item['default']) { |
|
| 72 | - $item = $item['displayName']; |
|
| 73 | - } else { |
|
| 74 | - $item = $item['displayName'] . ' [default*]'; |
|
| 75 | - } |
|
| 76 | - }); |
|
| 77 | - } |
|
| 63 | + /** |
|
| 64 | + * @param InputInterface $input |
|
| 65 | + * @param OutputInterface $output |
|
| 66 | + * @param array $items |
|
| 67 | + */ |
|
| 68 | + protected function writeModuleList(InputInterface $input, OutputInterface $output, $items) { |
|
| 69 | + if ($input->getOption('output') === self::OUTPUT_FORMAT_PLAIN) { |
|
| 70 | + array_walk($items, function(&$item) { |
|
| 71 | + if (!$item['default']) { |
|
| 72 | + $item = $item['displayName']; |
|
| 73 | + } else { |
|
| 74 | + $item = $item['displayName'] . ' [default*]'; |
|
| 75 | + } |
|
| 76 | + }); |
|
| 77 | + } |
|
| 78 | 78 | |
| 79 | - $this->writeArrayInOutputFormat($input, $output, $items); |
|
| 80 | - } |
|
| 79 | + $this->writeArrayInOutputFormat($input, $output, $items); |
|
| 80 | + } |
|
| 81 | 81 | } |
@@ -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 | } |