diff options
Diffstat (limited to 'core/Command/L10n/CreateJs.php')
-rw-r--r-- | core/Command/L10n/CreateJs.php | 49 |
1 files changed, 21 insertions, 28 deletions
diff --git a/core/Command/L10n/CreateJs.php b/core/Command/L10n/CreateJs.php index 6472e7aec1c..64a21e6d48c 100644 --- a/core/Command/L10n/CreateJs.php +++ b/core/Command/L10n/CreateJs.php @@ -1,31 +1,18 @@ <?php + +declare(strict_types=1); + /** - * @copyright Copyright (c) 2016, ownCloud, Inc. - * - * @author Christoph Wurst <christoph@winzerhof-wurst.at> - * @author Joas Schilling <coding@schilljs.com> - * @author Morris Jobke <hey@morrisjobke.de> - * @author Thomas Müller <thomas.mueller@tmit.eu> - * - * @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-2024 Nextcloud GmbH and Nextcloud contributors + * SPDX-FileCopyrightText: 2016 ownCloud, Inc. + * SPDX-License-Identifier: AGPL-3.0-only */ namespace OC\Core\Command\L10n; use DirectoryIterator; +use OCP\App\AppPathNotFoundException; +use OCP\App\IAppManager; use Stecman\Component\Symfony\Console\BashCompletion\Completion\CompletionAwareInterface; use Stecman\Component\Symfony\Console\BashCompletion\CompletionContext; use Symfony\Component\Console\Command\Command; @@ -35,6 +22,12 @@ use Symfony\Component\Console\Output\OutputInterface; use UnexpectedValueException; class CreateJs extends Command implements CompletionAwareInterface { + public function __construct( + protected IAppManager $appManager, + ) { + parent::__construct(); + } + protected function configure() { $this ->setName('l10n:createjs') @@ -55,11 +48,7 @@ class CreateJs extends Command implements CompletionAwareInterface { $app = $input->getArgument('app'); $lang = $input->getArgument('lang'); - $path = \OC_App::getAppPath($app); - if ($path === false) { - $output->writeln("The app <$app> is unknown."); - return 1; - } + $path = $this->appManager->getAppPath($app); $languages = $lang; if (empty($lang)) { $languages = $this->getAllLanguages($path); @@ -159,10 +148,14 @@ class CreateJs extends Command implements CompletionAwareInterface { */ public function completeArgumentValues($argumentName, CompletionContext $context) { if ($argumentName === 'app') { - return \OC_App::getAllApps(); + return $this->appManager->getAllAppsInAppsFolders(); } elseif ($argumentName === 'lang') { $appName = $context->getWordAtIndex($context->getWordIndex() - 1); - return $this->getAllLanguages(\OC_App::getAppPath($appName)); + try { + return $this->getAllLanguages($this->appManager->getAppPath($appName)); + } catch (AppPathNotFoundException) { + return []; + } } return []; } |