]> git.mxchange.org Git - friendica.git/commitdiff
Move code from console.php into App::processConsole()
authorArt4 <art4@wlabs.de>
Thu, 26 Dec 2024 07:44:19 +0000 (07:44 +0000)
committerArt4 <art4@wlabs.de>
Thu, 26 Dec 2024 07:44:19 +0000 (07:44 +0000)
bin/console.php
src/App.php

index 250131982f3297b771209ffc60e339a1006fdfce..1c502cc673c044f2808306ce434b679cb28bcf55 100755 (executable)
@@ -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'] ?? []);
index ecfaec370cfda4c23e45c49f34a90d4d9fc9acee..7aef7fe361db6b38154c639873cedbb0cbd19267 100644 (file)
@@ -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 */