mirror of
https://github.com/friendica/friendica
synced 2025-01-08 21:24:43 +00:00
Move getModule() code into App class
This commit is contained in:
parent
4d0a695588
commit
dde8291597
2 changed files with 20 additions and 19 deletions
19
src/App.php
19
src/App.php
|
@ -715,7 +715,24 @@ class App
|
||||||
/** @var Router $router */
|
/** @var Router $router */
|
||||||
$router = $this->container->create(Router::class);
|
$router = $this->container->create(Router::class);
|
||||||
|
|
||||||
return $router->getModule($this->container, $moduleClass);
|
$moduleClass = $moduleClass ?? $router->getModuleClass();
|
||||||
|
$parameters = $router->getParameters();
|
||||||
|
|
||||||
|
$dice_profiler_threshold = $this->config->get('system', 'dice_profiler_threshold', 0);
|
||||||
|
|
||||||
|
$stamp = microtime(true);
|
||||||
|
|
||||||
|
/** @var ICanHandleRequests $module */
|
||||||
|
$module = $this->container->create($moduleClass, $parameters);
|
||||||
|
|
||||||
|
if ($dice_profiler_threshold > 0) {
|
||||||
|
$dur = floatval(microtime(true) - $stamp);
|
||||||
|
if ($dur >= $dice_profiler_threshold) {
|
||||||
|
$this->logger->notice('Dice module creation lasts too long.', ['duration' => round($dur, 3), 'module' => $moduleClass, 'parameters' => $parameters]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $module;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -319,25 +319,9 @@ class Router
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getModule(Dice $dice, ?string $module_class = null): ICanHandleRequests
|
public function getParameters(): array
|
||||||
{
|
{
|
||||||
$moduleClass = $module_class ?? $this->getModuleClass();
|
return $this->parameters;
|
||||||
|
|
||||||
$dice_profiler_threshold = $this->config->get('system', 'dice_profiler_threshold', 0);
|
|
||||||
|
|
||||||
$stamp = microtime(true);
|
|
||||||
|
|
||||||
/** @var ICanHandleRequests $module */
|
|
||||||
$module = $dice->create($moduleClass, $this->parameters);
|
|
||||||
|
|
||||||
if ($dice_profiler_threshold > 0) {
|
|
||||||
$dur = floatval(microtime(true) - $stamp);
|
|
||||||
if ($dur >= $dice_profiler_threshold) {
|
|
||||||
$this->logger->notice('Dice module creation lasts too long.', ['duration' => round($dur, 3), 'module' => $moduleClass, 'parameters' => $this->parameters]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $module;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue