diff options
Diffstat (limited to 'core/Command/App/Enable.php')
-rw-r--r-- | core/Command/App/Enable.php | 58 |
1 files changed, 19 insertions, 39 deletions
diff --git a/core/Command/App/Enable.php b/core/Command/App/Enable.php index c7a071e27b5..3936acfbf6e 100644 --- a/core/Command/App/Enable.php +++ b/core/Command/App/Enable.php @@ -1,27 +1,10 @@ <?php + +declare(strict_types=1); + /** - * @copyright Copyright (c) 2016, ownCloud, Inc. - * - * @author Daniel Kesselberg <mail@danielkesselberg.de> - * @author Joas Schilling <coding@schilljs.com> - * @author John Molakvoæ <skjnldsv@protonmail.com> - * @author Robin Appelman <robin@icewind.nl> - * @author Sander Ruitenbeek <s.ruitenbeek@getgoing.nl> - * - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see <http://www.gnu.org/licenses/> - * + * SPDX-FileCopyrightText: 2016 ownCloud, Inc. + * SPDX-License-Identifier: AGPL-3.0-only */ namespace OC\Core\Command\App; @@ -39,14 +22,14 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; class Enable extends Command implements CompletionAwareInterface { - protected IAppManager $appManager; - protected IGroupManager $groupManager; protected int $exitCode = 0; - public function __construct(IAppManager $appManager, IGroupManager $groupManager) { + public function __construct( + protected IAppManager $appManager, + protected IGroupManager $groupManager, + private Installer $installer, + ) { parent::__construct(); - $this->appManager = $appManager; - $this->groupManager = $groupManager; } protected function configure(): void { @@ -75,7 +58,7 @@ class Enable extends Command implements CompletionAwareInterface { protected function execute(InputInterface $input, OutputInterface $output): int { $appIds = $input->getArgument('app-id'); $groups = $this->resolveGroupIds($input->getOption('groups')); - $forceEnable = (bool) $input->getOption('force'); + $forceEnable = (bool)$input->getOption('force'); foreach ($appIds as $appId) { $this->enableApp($appId, $groups, $forceEnable, $output); @@ -95,21 +78,18 @@ class Enable extends Command implements CompletionAwareInterface { return $group->getDisplayName(); }, $groupIds); - if ($this->appManager->isInstalled($appId) && $groupIds === []) { + if ($this->appManager->isEnabledForUser($appId) && $groupIds === []) { $output->writeln($appId . ' already enabled'); return; } try { - /** @var Installer $installer */ - $installer = \OC::$server->query(Installer::class); - - if (false === $installer->isDownloaded($appId)) { - $installer->downloadApp($appId); + if ($this->installer->isDownloaded($appId) === false) { + $this->installer->downloadApp($appId); } - $installer->installApp($appId, $forceEnable); - $appVersion = \OC_App::getAppVersion($appId); + $this->installer->installApp($appId, $forceEnable); + $appVersion = $this->appManager->getAppVersion($appId); if ($groupIds === []) { $this->appManager->enableApp($appId, $forceEnable); @@ -147,7 +127,7 @@ class Enable extends Command implements CompletionAwareInterface { * @param CompletionContext $context * @return string[] */ - public function completeOptionValues($optionName, CompletionContext $context) { + public function completeOptionValues($optionName, CompletionContext $context): array { if ($optionName === 'groups') { return array_map(function (IGroup $group) { return $group->getGID(); @@ -161,9 +141,9 @@ class Enable extends Command implements CompletionAwareInterface { * @param CompletionContext $context * @return string[] */ - public function completeArgumentValues($argumentName, CompletionContext $context) { + public function completeArgumentValues($argumentName, CompletionContext $context): array { if ($argumentName === 'app-id') { - $allApps = \OC_App::getAllApps(); + $allApps = $this->appManager->getAllAppsInAppsFolders(); return array_diff($allApps, \OC_App::getEnabledApps(true, true)); } return []; |