aboutsummaryrefslogtreecommitdiffstats
path: root/core/Command/App/GetPath.php
diff options
context:
space:
mode:
Diffstat (limited to 'core/Command/App/GetPath.php')
-rw-r--r--core/Command/App/GetPath.php54
1 files changed, 24 insertions, 30 deletions
diff --git a/core/Command/App/GetPath.php b/core/Command/App/GetPath.php
index 2ec72385191..3ba4ed7781b 100644
--- a/core/Command/App/GetPath.php
+++ b/core/Command/App/GetPath.php
@@ -1,35 +1,29 @@
<?php
+
+declare(strict_types=1);
+
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Joas Schilling <coding@schilljs.com>
- * @author Victor Dubiniuk <dubiniuk@owncloud.com>
- *
- * @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;
use OC\Core\Command\Base;
+use OCP\App\AppPathNotFoundException;
+use OCP\App\IAppManager;
use Stecman\Component\Symfony\Console\BashCompletion\CompletionContext;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class GetPath extends Base {
- protected function configure() {
+ public function __construct(
+ protected IAppManager $appManager,
+ ) {
+ parent::__construct();
+ }
+
+ protected function configure(): void {
parent::configure();
$this
@@ -46,20 +40,20 @@ class GetPath extends Base {
/**
* Executes the current command.
*
- * @param InputInterface $input An InputInterface instance
+ * @param InputInterface $input An InputInterface instance
* @param OutputInterface $output An OutputInterface instance
* @return int 0 if everything went fine, or an error code
*/
protected function execute(InputInterface $input, OutputInterface $output): int {
$appName = $input->getArgument('app');
- $path = \OC_App::getAppPath($appName);
- if ($path !== false) {
- $output->writeln($path);
- return 0;
+ try {
+ $path = $this->appManager->getAppPath($appName);
+ } catch (AppPathNotFoundException) {
+ // App not found, exit with non-zero
+ return self::FAILURE;
}
-
- // App not found, exit with non-zero
- return 1;
+ $output->writeln($path);
+ return self::SUCCESS;
}
/**
@@ -67,9 +61,9 @@ class GetPath extends Base {
* @param CompletionContext $context
* @return string[]
*/
- public function completeArgumentValues($argumentName, CompletionContext $context) {
+ public function completeArgumentValues($argumentName, CompletionContext $context): array {
if ($argumentName === 'app') {
- return \OC_App::getAllApps();
+ return $this->appManager->getAllAppsInAppsFolders();
}
return [];
}