]> git.mxchange.org Git - friendica.git/commitdiff
remove constructor injection of Dice in Router
authorArt4 <art4@wlabs.de>
Sat, 28 Dec 2024 13:10:28 +0000 (13:10 +0000)
committerArt4 <art4@wlabs.de>
Sat, 28 Dec 2024 13:10:28 +0000 (13:10 +0000)
src/App.php
src/App/Router.php
static/dependencies.config.php

index a0dd06521ccbf43bb146d39125087a247facba76..68cae8083002a4e32977274065d4933102a07da1 100644 (file)
@@ -715,7 +715,7 @@ class App
                /** @var Router $router */
                $router = $this->container->create(Router::class);
 
-               return $router->getModule($moduleClass);
+               return $router->getModule($this->container, $moduleClass);
        }
 
        /**
index 31162ec1b6a3670ed28cddb3094857d41c097130..c0ec7b1e1ee9d80eb34dcb1b3a6b8ad7ad437734 100644 (file)
@@ -92,9 +92,6 @@ class Router
        /** @var float */
        private $dice_profiler_threshold;
 
-       /** @var Dice */
-       private $dice;
-
        /** @var string */
        private $baseRoutesFilepath;
 
@@ -113,11 +110,10 @@ class Router
         * @param IManageConfigValues $config
         * @param Arguments           $args
         * @param LoggerInterface     $logger
-        * @param Dice                $dice
         * @param IHandleUserSessions $userSession
         * @param RouteCollector|null $routeCollector
         */
-       public function __construct(array $server, string $baseRoutesFilepath, L10n $l10n, ICanCache $cache, ICanLock $lock, IManageConfigValues $config, Arguments $args, LoggerInterface $logger, Dice $dice, IHandleUserSessions $userSession, RouteCollector $routeCollector = null)
+       public function __construct(array $server, string $baseRoutesFilepath, L10n $l10n, ICanCache $cache, ICanLock $lock, IManageConfigValues $config, Arguments $args, LoggerInterface $logger, IHandleUserSessions $userSession, RouteCollector $routeCollector = null)
        {
                $this->baseRoutesFilepath      = $baseRoutesFilepath;
                $this->l10n                    = $l10n;
@@ -125,7 +121,6 @@ class Router
                $this->lock                    = $lock;
                $this->args                    = $args;
                $this->config                  = $config;
-               $this->dice                    = $dice;
                $this->server                  = $server;
                $this->logger                  = $logger;
                $this->isLocalUser             = !empty($userSession->getLocalUserId());
@@ -328,14 +323,14 @@ class Router
                }
        }
 
-       public function getModule(?string $module_class = null): ICanHandleRequests
+       public function getModule(Dice $dice, ?string $module_class = null): ICanHandleRequests
        {
                $moduleClass = $module_class ?? $this->getModuleClass();
 
                $stamp = microtime(true);
 
                /** @var ICanHandleRequests $module */
-               $module = $this->dice->create($moduleClass, $this->parameters);
+               $module = $dice->create($moduleClass, $this->parameters);
 
                if ($this->dice_profiler_threshold > 0) {
                        $dur = floatval(microtime(true) - $stamp);
index 93d9de81ac04add1e371f3f1d59c0ad9d7df5828..28ae277c218325895f005d5edbb8ff6fcc5977fd 100644 (file)
@@ -219,7 +219,6 @@ return (function(string $basepath, array $getVars, array $serverVars, array $coo
                        'constructParams' => [
                                $serverVars,
                                __DIR__ . '/routes.config.php',
-                               [Dice::INSTANCE => Dice::SELF],
                                null
                        ],
                ],