diff --git a/bin/auth_ejabberd.php b/bin/auth_ejabberd.php index c44cd65ff6..30202bbd93 100755 --- a/bin/auth_ejabberd.php +++ b/bin/auth_ejabberd.php @@ -45,31 +45,13 @@ if (php_sapi_name() !== 'cli') { } use Dice\Dice; -use Friendica\App\Mode; -use Friendica\Core\Logger\Capability\LogChannel; -use Friendica\Security\ExAuth; -use Psr\Log\LoggerInterface; chdir(dirname(__FILE__, 2)); -require dirname(__DIR__) . '/vendor/autoload.php'; +require dirname(__FILE__, 2) . '/vendor/autoload.php'; $dice = (new Dice())->addRules(require(dirname(__FILE__, 2) . '/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::AUTH_JABBERED]]); -\Friendica\DI::init($dice); -\Friendica\Core\Logger\Handler\ErrorHandler::register($dice->create(\Psr\Log\LoggerInterface::class)); +$app = \Friendica\App::fromDice($dice); -// Check the database structure and possibly fixes it -\Friendica\Core\Update::check(\Friendica\DI::basePath(), true); - -$appMode = $dice->create(Mode::class); - -if ($appMode->isNormal()) { - /** @var ExAuth $oAuth */ - $oAuth = $dice->create(ExAuth::class); - $oAuth->readStdin(); -} +$app->processEjabberd(); diff --git a/src/App.php b/src/App.php index 2c236390d1..40d8cf092d 100644 --- a/src/App.php +++ b/src/App.php @@ -23,12 +23,14 @@ use Friendica\Database\Definition\ViewDefinition; use Friendica\Module\Maintenance; use Friendica\Security\Authentication; use Friendica\Core\Config\Capability\IManageConfigValues; +use Friendica\Core\Logger\Capability\LogChannel; use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues; use Friendica\Core\L10n; use Friendica\Core\System; use Friendica\Module\Special\HTTPException as ModuleHTTPException; use Friendica\Network\HTTPException; use Friendica\Protocol\ATProtocol\DID; +use Friendica\Security\ExAuth; use Friendica\Security\OpenWebAuth; use Friendica\Util\DateTimeFormat; use Friendica\Util\HTTPInputData; @@ -156,6 +158,30 @@ class App ); } + public function processEjabberd(): 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::AUTH_JABBERED], + ]); + + \Friendica\DI::init($this->container); + \Friendica\Core\Logger\Handler\ErrorHandler::register($this->container->create(LoggerInterface::class)); + + // Check the database structure and possibly fixes it + \Friendica\Core\Update::check(\Friendica\DI::basePath(), true); + + $appMode = $this->container->create(Mode::class); + + if ($appMode->isNormal()) { + /** @var ExAuth $oAuth */ + $oAuth = $this->container->create(ExAuth::class); + $oAuth->readStdin(); + } + } + private function setupContainerForRunningFrontend(ServerRequestInterface $request): void { /** @var \Friendica\Core\Addon\Capability\ICanLoadAddons $addonLoader */