]> git.mxchange.org Git - friendica.git/commitdiff
Move adding Dice rules into App
authorArt4 <art4@wlabs.de>
Mon, 23 Dec 2024 15:22:27 +0000 (15:22 +0000)
committerArt4 <art4@wlabs.de>
Mon, 23 Dec 2024 15:22:27 +0000 (15:22 +0000)
index.php
src/App.php

index f936cd1a3aa14f0f5c1e44e148064d7ab7a85831..8ba10df263f0040d5c8c6bd9380e51d91ee5484e 100644 (file)
--- a/index.php
+++ b/index.php
@@ -18,14 +18,6 @@ require __DIR__ . '/vendor/autoload.php';
 $request = \GuzzleHttp\Psr7\ServerRequest::fromGlobals();
 
 $dice = (new Dice())->addRules(include __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(Friendica\App\Mode::class, ['call' => [['determineRunMode', [false, $request->getServerParams()], Dice::CHAIN_CALL]]]);
-
-\Friendica\DI::init($dice);
-
-\Friendica\Core\Logger\Handler\ErrorHandler::register($dice->create(\Psr\Log\LoggerInterface::class));
 
 $a = \Friendica\App::fromDice($dice);
 
index bc3efde1760004c924981ee5efb2adadb74a4c6e..e3a9ac093675ced126788887050ae9b18a7233a3 100644 (file)
@@ -121,6 +121,8 @@ class App
 
        public function processRequest(ServerRequestInterface $request, float $start_time): void
        {
+               $this->setupContainerForRunningFrontend($request);
+
                $this->requestId = $this->container->create(Request::class)->getRequestId();
                $this->auth      = $this->container->create(Authentication::class);
                $this->config    = $this->container->create(IManageConfigValues::class);
@@ -152,6 +154,18 @@ class App
                );
        }
 
+       private function setupContainerForRunningFrontend(ServerRequestInterface $request): 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(\Friendica\App\Mode::class, ['call' => [['determineRunMode', [false, $request->getServerParams()], Dice::CHAIN_CALL]]]);
+
+               \Friendica\DI::init($this->container);
+
+               \Friendica\Core\Logger\Handler\ErrorHandler::register($this->container->create(\Psr\Log\LoggerInterface::class));
+       }
+
        /**
         * Load the whole app instance
         */