diff options
author | Côme Chilliet <come.chilliet@nextcloud.com> | 2024-03-06 11:54:58 +0100 |
---|---|---|
committer | Côme Chilliet <come.chilliet@nextcloud.com> | 2024-04-22 12:14:58 +0200 |
commit | 644036ab4e3d1d6f175a485ed7ae4883c668ff48 (patch) | |
tree | c11aba914ce246805c420270d0e5bb828c58ee1a /core/Command/App/GetPath.php | |
parent | 683dc07f06018e72e46f067a306dc14408ce91f9 (diff) | |
download | nextcloud-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.php | 27 |
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 []; } |