Skip to content
Prev Previous commit
Next Next commit
fix: use DI to build main Application class in console.php
Signed-off-by: Côme Chilliet <[email protected]>
  • Loading branch information
come-nc committed Apr 22, 2024
commit 8c5f32320a3ceeb9aac86bb2340d0919adf37993
14 changes: 5 additions & 9 deletions console.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php

declare(strict_types=1);

/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
Expand Down Expand Up @@ -57,7 +60,7 @@ function exceptionHandler($exception) {
exit(1);
}

$config = \OC::$server->getConfig();
$config = \OCP\Server::get(\OCP\IConfig::class);
set_exception_handler('exceptionHandler');

if (!function_exists('posix_getuid')) {
Expand Down Expand Up @@ -102,14 +105,7 @@ function exceptionHandler($exception) {
echo "Additionally the function 'pcntl_signal' and 'pcntl_signal_dispatch' need to be enabled in your php.ini." . PHP_EOL;
}

$application = new Application(
$config,
\OC::$server->get(\OCP\EventDispatcher\IEventDispatcher::class),
\OC::$server->getRequest(),
\OC::$server->get(\Psr\Log\LoggerInterface::class),
\OC::$server->query(\OC\MemoryInfo::class),
\OCP\Server::get(\OCP\App\IAppManager::class),
);
$application = \OCP\Server::get(Application::class);
$application->loadCommands(new ArgvInput(), new ConsoleOutput());
$application->run();
} catch (Exception $ex) {
Expand Down
2 changes: 1 addition & 1 deletion core/Command/App/Remove.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public function completeOptionValues($optionName, CompletionContext $context): a
*/
public function completeArgumentValues($argumentName, CompletionContext $context): array {
if ($argumentName === 'app-id') {
return $this->appManager->getInstalledApps();
return $this->manager->getInstalledApps();
}
return [];
}
Expand Down