]> git.mxchange.org Git - friendica.git/commitdiff
Move setupLegacyServiceLocator() into App class
authorArt4 <art4@wlabs.de>
Thu, 9 Jan 2025 13:34:10 +0000 (13:34 +0000)
committerArt4 <art4@wlabs.de>
Thu, 9 Jan 2025 13:34:10 +0000 (13:34 +0000)
src/App.php
src/Core/DiceContainer.php

index 17254bb96684eced1399ac44bd736343788868c9..c1ac8b2d4387f29cb4fa9f678ff8fe6bbbdad386 100644 (file)
@@ -27,6 +27,7 @@ use Friendica\Database\Definition\ViewDefinition;
 use Friendica\Module\Maintenance;
 use Friendica\Security\Authentication;
 use Friendica\Core\Config\Capability\IManageConfigValues;
+use Friendica\Core\DiceContainer;
 use Friendica\Core\L10n;
 use Friendica\Core\Logger\Capability\LogChannel;
 use Friendica\Core\Logger\Handler\ErrorHandler;
@@ -140,7 +141,7 @@ class App
 
                $this->setupContainerForLogger(LogChannel::APP);
 
-               $this->container->setup();
+               $this->setupLegacyServiceLocator();
 
                $this->registerErrorHandler();
 
@@ -182,7 +183,7 @@ class App
 
                $this->setupContainerForLogger($this->determineLogChannel($argv));
 
-               $this->container->setup();
+               $this->setupLegacyServiceLocator();
 
                $this->registerErrorHandler();
 
@@ -197,7 +198,7 @@ class App
 
                $this->setupContainerForLogger(LogChannel::AUTH_JABBERED);
 
-               $this->container->setup();
+               $this->setupLegacyServiceLocator();
 
                $this->registerErrorHandler();
 
@@ -250,6 +251,13 @@ class App
                ]);
        }
 
+       private function setupLegacyServiceLocator(): void
+       {
+               if ($this->container instanceof DiceContainer) {
+                       DI::init($this->container->getDice());
+               }
+       }
+
        private function registerErrorHandler(): void
        {
                ErrorHandler::register($this->container->create(LoggerInterface::class));
index 778192388b1521fe1953408d177d2ea75dc466df..acbb0862b9c8277edec340ff2bc5ce201dbb6ced 100644 (file)
@@ -10,7 +10,6 @@ declare(strict_types=1);
 namespace Friendica\Core;
 
 use Dice\Dice;
-use Friendica\DI;
 
 /**
  * Wrapper for the Dice class to make some basic setups
@@ -42,7 +41,7 @@ final class DiceContainer implements Container
         */
        public function setup(): void
        {
-               $this->setupLegacyServiceLocator();
+               // this method can be removed
        }
 
        /**
@@ -71,8 +70,17 @@ final class DiceContainer implements Container
                $this->container = $this->container->addRule($name, $rule);
        }
 
-       private function setupLegacyServiceLocator(): void
+       /**
+        * Only used to inject Dice into DI class
+        *
+        * @see \Friendica\DI
+        *
+        * @internal
+        *
+        * @deprecated
+        */
+       public function getDice(): Dice
        {
-               DI::init($this->container);
+               return $this->container;
        }
 }