Move code from console.php into App::processConsole()

This commit is contained in:
Art4 2024-12-26 07:44:19 +00:00
parent 907e07a4c4
commit f40b428ac2
2 changed files with 16 additions and 12 deletions

View file

@ -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'] ?? []);

View 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 */