aboutsummaryrefslogtreecommitdiffstats
path: root/core/Command/App/GetPath.php
diff options
context:
space:
mode:
authorCôme Chilliet <come.chilliet@nextcloud.com>2024-03-06 11:54:58 +0100
committerCôme Chilliet <come.chilliet@nextcloud.com>2024-04-22 12:14:58 +0200
commit644036ab4e3d1d6f175a485ed7ae4883c668ff48 (patch)
treec11aba914ce246805c420270d0e5bb828c58ee1a /core/Command/App/GetPath.php
parent683dc07f06018e72e46f067a306dc14408ce91f9 (diff)
downloadnextcloud-server-644036ab4e3d1d6f175a485ed7ae4883c668ff48.tar.gz
nextcloud-server-644036ab4e3d1d6f175a485ed7ae4883c668ff48.zip
fix: Migrate away from OC_App toward the IAppManager
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'core/Command/App/GetPath.php')
-rw-r--r--core/Command/App/GetPath.php27
1 files changed, 19 insertions, 8 deletions
diff --git a/core/Command/App/GetPath.php b/core/Command/App/GetPath.php
index ea614070e7d..844e14ffdde 100644
--- a/core/Command/App/GetPath.php
+++ b/core/Command/App/GetPath.php
@@ -1,4 +1,7 @@
<?php
+
+declare(strict_types=1);
+
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
@@ -23,12 +26,20 @@
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 {
+ public function __construct(
+ protected IAppManager $appManager,
+ ) {
+ parent::__construct();
+ }
+
protected function configure(): void {
parent::configure();
@@ -52,14 +63,14 @@ class GetPath extends Base {
*/
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;
}
/**
@@ -69,7 +80,7 @@ class GetPath extends Base {
*/
public function completeArgumentValues($argumentName, CompletionContext $context): array {
if ($argumentName === 'app') {
- return \OC_App::getAllApps();
+ return $this->appManager->getInstalledApps();
}
return [];
}