aboutsummaryrefslogtreecommitdiffstats
path: root/core/Command
diff options
context:
space:
mode:
authorDaniel Kesselberg <mail@danielkesselberg.de>2019-01-27 14:34:39 +0100
committerDaniel Kesselberg <mail@danielkesselberg.de>2019-02-19 21:03:05 +0100
commit03d31926385624abe4b24b98dee93e132049889c (patch)
tree0907742258d896fb1120a28a27b1cb9df190bdb1 /core/Command
parent08907ee3e9a4267daa2268f20ed9dee3c9cc3328 (diff)
downloadnextcloud-server-03d31926385624abe4b24b98dee93e132049889c.tar.gz
nextcloud-server-03d31926385624abe4b24b98dee93e132049889c.zip
Disable multiple apps at once
Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
Diffstat (limited to 'core/Command')
-rw-r--r--core/Command/App/Disable.php47
1 files changed, 30 insertions, 17 deletions
diff --git a/core/Command/App/Disable.php b/core/Command/App/Disable.php
index b64e309bd97..a79c9c474db 100644
--- a/core/Command/App/Disable.php
+++ b/core/Command/App/Disable.php
@@ -36,39 +36,52 @@ use Symfony\Component\Console\Output\OutputInterface;
class Disable extends Command implements CompletionAwareInterface {
/** @var IAppManager */
- protected $manager;
+ protected $appManager;
+
+ /** @var int */
+ protected $exitCode = 0;
/**
- * @param IAppManager $manager
+ * @param IAppManager $appManager
*/
- public function __construct(IAppManager $manager) {
+ public function __construct(IAppManager $appManager) {
parent::__construct();
- $this->manager = $manager;
+ $this->appManager = $appManager;
}
- protected function configure() {
+ protected function configure(): void {
$this
->setName('app:disable')
->setDescription('disable an app')
->addArgument(
'app-id',
- InputArgument::REQUIRED,
+ InputArgument::REQUIRED | InputArgument::IS_ARRAY,
'disable the specified app'
);
}
protected function execute(InputInterface $input, OutputInterface $output) {
- $appId = $input->getArgument('app-id');
- if ($this->manager->isInstalled($appId)) {
- try {
- $this->manager->disableApp($appId);
- $output->writeln($appId . ' disabled');
- } catch(\Exception $e) {
- $output->writeln($e->getMessage());
- return 2;
- }
- } else {
+ $appIds = $input->getArgument('app-id');
+
+ foreach ($appIds as $appId) {
+ $this->disableApp($appId, $output);
+ }
+
+ return $this->exitCode;
+ }
+
+ private function disableApp(string $appId, OutputInterface $output): void {
+ if ($this->appManager->isInstalled($appId) === false) {
$output->writeln('No such app enabled: ' . $appId);
+ return;
+ }
+
+ try {
+ $this->appManager->disableApp($appId);
+ $output->writeln($appId . ' disabled');
+ } catch (\Exception $e) {
+ $output->writeln($e->getMessage());
+ $this->exitCode = 2;
}
}
@@ -88,7 +101,7 @@ class Disable extends Command implements CompletionAwareInterface {
*/
public function completeArgumentValues($argumentName, CompletionContext $context) {
if ($argumentName === 'app-id') {
- return array_diff(\OC_App::getEnabledApps(true, true), $this->manager->getAlwaysEnabledApps());
+ return array_diff(\OC_App::getEnabledApps(true, true), $this->appManager->getAlwaysEnabledApps());
}
return [];
}