From 182732b1128f2e05890d6a3b70d9f8d531f0e848 Mon Sep 17 00:00:00 2001 From: Art4 Date: Sat, 28 Dec 2024 13:07:07 +0000 Subject: [PATCH] Extract create module into own method --- src/App.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/App.php b/src/App.php index f673c2eb39..a0dd06521c 100644 --- a/src/App.php +++ b/src/App.php @@ -15,6 +15,7 @@ use Friendica\App\Page; use Friendica\App\Request; use Friendica\App\Router; use Friendica\Capabilities\ICanCreateResponses; +use Friendica\Capabilities\ICanHandleRequests; use Friendica\Content\Nav; use Friendica\Core\Config\Factory\Config; use Friendica\Core\KeyValueStorage\Capability\IManageKeyValuePairs; @@ -672,16 +673,13 @@ class App // Initialize module that can set the current theme in the init() method, either directly or via App->setProfileOwner $page['page_title'] = $moduleName; - /** @var Router $router */ - $router = $this->container->create(Router::class); - // The "view" module is required to show the theme CSS if (!$this->mode->isInstall() && !$this->mode->has(Mode::MAINTENANCEDISABLED) && $moduleName !== 'view') { - $module = $router->getModule(Maintenance::class); + $module = $this->createModuleInstance(Maintenance::class); } else { // determine the module class and save it to the module instance // @todo there's an implicit dependency due SESSION::start(), so it has to be called here (yet) - $module = $router->getModule(); + $module = $this->createModuleInstance(null); } // Display can change depending on the requested language, so it shouldn't be cached whole @@ -712,6 +710,14 @@ class App $page->logRuntime($this->config, 'runFrontend'); } + private function createModuleInstance(?string $moduleClass = null): ICanHandleRequests + { + /** @var Router $router */ + $router = $this->container->create(Router::class); + + return $router->getModule($moduleClass); + } + /** * Log slow page executions *