From fa315cf44af6ce4fb095ab1b61026397ce9a6079 Mon Sep 17 00:00:00 2001 From: Art4 Date: Sat, 28 Dec 2024 13:10:28 +0000 Subject: [PATCH] remove constructor injection of Dice in Router --- src/App.php | 2 +- src/App/Router.php | 11 +++-------- static/dependencies.config.php | 1 - 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/App.php b/src/App.php index a0dd06521c..68cae80830 100644 --- a/src/App.php +++ b/src/App.php @@ -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); } /** diff --git a/src/App/Router.php b/src/App/Router.php index 31162ec1b6..c0ec7b1e1e 100644 --- a/src/App/Router.php +++ b/src/App/Router.php @@ -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); diff --git a/static/dependencies.config.php b/static/dependencies.config.php index 93d9de81ac..28ae277c21 100644 --- a/static/dependencies.config.php +++ b/static/dependencies.config.php @@ -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 ], ],