From f40b428ac222bbb00e3f96fee9c8a7054cb68083 Mon Sep 17 00:00:00 2001 From: Art4 Date: Thu, 26 Dec 2024 07:44:19 +0000 Subject: [PATCH] Move code from console.php into App::processConsole() --- bin/console.php | 14 ++------------ src/App.php | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/bin/console.php b/bin/console.php index 250131982f..1c502cc673 100755 --- a/bin/console.php +++ b/bin/console.php @@ -14,21 +14,11 @@ if (php_sapi_name() !== 'cli') { } use Dice\Dice; -use Friendica\Core\Logger\Capability\LogChannel; -use Friendica\DI; -use Psr\Log\LoggerInterface; require dirname(__DIR__) . '/vendor/autoload.php'; $dice = (new Dice())->addRules(require(dirname(__DIR__) . '/static/dependencies.config.php')); -/** @var \Friendica\Core\Addon\Capability\ICanLoadAddons $addonLoader */ -$addonLoader = $dice->create(\Friendica\Core\Addon\Capability\ICanLoadAddons::class); -$dice = $dice->addRules($addonLoader->getActiveAddonConfig('dependencies')); -$dice = $dice->addRule(LoggerInterface::class, ['constructParams' => [LogChannel::CONSOLE]]); +$app = \Friendica\App::fromDice($dice); -/// @fixme Necessary until Hooks inside the Logger can get loaded without the DI-class -DI::init($dice); -\Friendica\Core\Logger\Handler\ErrorHandler::register($dice->create(\Psr\Log\LoggerInterface::class)); - -(new Friendica\Core\Console($dice, $_SERVER['argv'] ?? []))->execute(); +$app->processConsole($_SERVER['argv'] ?? []); diff --git a/src/App.php b/src/App.php index ecfaec370c..7aef7fe361 100644 --- a/src/App.php +++ b/src/App.php @@ -190,6 +190,20 @@ class App } } + public function processConsole(array $argv): void + { + /** @var \Friendica\Core\Addon\Capability\ICanLoadAddons $addonLoader */ + $addonLoader = $this->container->create(\Friendica\Core\Addon\Capability\ICanLoadAddons::class); + $this->container = $this->container->addRules($addonLoader->getActiveAddonConfig('dependencies')); + $this->container = $this->container->addRule(LoggerInterface::class, ['constructParams' => [LogChannel::CONSOLE]]); + + /// @fixme Necessary until Hooks inside the Logger can get loaded without the DI-class + DI::init($this->container); + \Friendica\Core\Logger\Handler\ErrorHandler::register($this->container->create(\Psr\Log\LoggerInterface::class)); + + (new \Friendica\Core\Console($this->container, $argv))->execute(); + } + private function setupContainerForAddons(): void { /** @var \Friendica\Core\Addon\Capability\ICanLoadAddons $addonLoader */