Refactor App::fromDice()

This commit is contained in:
Art4 2024-12-20 12:30:05 +00:00
parent 9e4f39b4fb
commit 0ab9c23bb9

View file

@ -55,20 +55,7 @@ class App
public static function fromDice(Dice $dice): self public static function fromDice(Dice $dice): self
{ {
return new self( return new self($dice);
$dice,
$dice->create(Request::class),
$dice->create(Authentication::class),
$dice->create(IManageConfigValues::class),
$dice->create(Mode::class),
$dice->create(BaseURL::class),
$dice->create(LoggerInterface::class),
$dice->create(Profiler::class),
$dice->create(L10n::class),
$dice->create(Arguments::class),
$dice->create(IHandleUserSessions::class),
$dice->create(AppHelper::class)
);
} }
/** /**
@ -127,32 +114,20 @@ class App
*/ */
private $appHelper; private $appHelper;
private function __construct( private function __construct(Dice $container)
Dice $container, {
Request $request,
Authentication $auth,
IManageConfigValues $config,
Mode $mode,
BaseURL $baseURL,
LoggerInterface $logger,
Profiler $profiler,
L10n $l10n,
Arguments $args,
IHandleUserSessions $session,
AppHelper $appHelper,
) {
$this->container = $container; $this->container = $container;
$this->requestId = $request->getRequestId(); $this->requestId = $this->container->create(Request::class)->getRequestId();
$this->auth = $auth; $this->auth = $this->container->create(Authentication::class);
$this->config = $config; $this->config = $this->container->create(IManageConfigValues::class);
$this->mode = $mode; $this->mode = $this->container->create(Mode::class);
$this->baseURL = $baseURL; $this->baseURL = $this->container->create(BaseURL::class);
$this->profiler = $profiler; $this->logger = $this->container->create(LoggerInterface::class);
$this->logger = $logger; $this->profiler = $this->container->create(Profiler::class);
$this->l10n = $l10n; $this->l10n = $this->container->create(L10n::class);
$this->args = $args; $this->args = $this->container->create(Arguments::class);
$this->session = $session; $this->session = $this->container->create(IHandleUserSessions::class);
$this->appHelper = $appHelper; $this->appHelper = $this->container->create(AppHelper::class);
} }
public function processRequest(ServerRequestInterface $request, float $start_time): void public function processRequest(ServerRequestInterface $request, float $start_time): void