mirror of
https://github.com/friendica/friendica
synced 2025-01-09 03:24:44 +00:00
Merge pull request #14620 from Art4/refactor-entrypoint-index.php
Refactor entrypoint in `index.php`
This commit is contained in:
commit
90181759cd
2 changed files with 26 additions and 10 deletions
12
index.php
12
index.php
|
@ -18,15 +18,7 @@ require __DIR__ . '/vendor/autoload.php';
|
||||||
$request = \GuzzleHttp\Psr7\ServerRequest::fromGlobals();
|
$request = \GuzzleHttp\Psr7\ServerRequest::fromGlobals();
|
||||||
|
|
||||||
$dice = (new Dice())->addRules(include __DIR__ . '/static/dependencies.config.php');
|
$dice = (new Dice())->addRules(include __DIR__ . '/static/dependencies.config.php');
|
||||||
/** @var \Friendica\Core\Addon\Capability\ICanLoadAddons $addonLoader */
|
|
||||||
$addonLoader = $dice->create(\Friendica\Core\Addon\Capability\ICanLoadAddons::class);
|
|
||||||
$dice = $dice->addRules($addonLoader->getActiveAddonConfig('dependencies'));
|
|
||||||
$dice = $dice->addRule(Friendica\App\Mode::class, ['call' => [['determineRunMode', [false, $request->getServerParams()], Dice::CHAIN_CALL]]]);
|
|
||||||
|
|
||||||
\Friendica\DI::init($dice);
|
$app = \Friendica\App::fromDice($dice);
|
||||||
|
|
||||||
\Friendica\Core\Logger\Handler\ErrorHandler::register($dice->create(\Psr\Log\LoggerInterface::class));
|
$app->processRequest($request, $start_time);
|
||||||
|
|
||||||
$a = \Friendica\App::fromDice($dice);
|
|
||||||
|
|
||||||
$a->processRequest($request, $start_time);
|
|
||||||
|
|
24
src/App.php
24
src/App.php
|
@ -121,6 +121,10 @@ class App
|
||||||
|
|
||||||
public function processRequest(ServerRequestInterface $request, float $start_time): void
|
public function processRequest(ServerRequestInterface $request, float $start_time): void
|
||||||
{
|
{
|
||||||
|
$this->setupContainerForRunningFrontend($request);
|
||||||
|
|
||||||
|
$this->registerErrorHandler();
|
||||||
|
|
||||||
$this->requestId = $this->container->create(Request::class)->getRequestId();
|
$this->requestId = $this->container->create(Request::class)->getRequestId();
|
||||||
$this->auth = $this->container->create(Authentication::class);
|
$this->auth = $this->container->create(Authentication::class);
|
||||||
$this->config = $this->container->create(IManageConfigValues::class);
|
$this->config = $this->container->create(IManageConfigValues::class);
|
||||||
|
@ -152,6 +156,26 @@ class App
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function setupContainerForRunningFrontend(ServerRequestInterface $request): void
|
||||||
|
{
|
||||||
|
/** @var \Friendica\Core\Addon\Capability\ICanLoadAddons $addonLoader */
|
||||||
|
$addonLoader = $this->container->create(\Friendica\Core\Addon\Capability\ICanLoadAddons::class);
|
||||||
|
|
||||||
|
$this->container = $this->container->addRules($addonLoader->getActiveAddonConfig('dependencies'));
|
||||||
|
$this->container = $this->container->addRule(Mode::class, [
|
||||||
|
'call' => [
|
||||||
|
['determineRunMode', [false, $request->getServerParams()], Dice::CHAIN_CALL],
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
|
||||||
|
\Friendica\DI::init($this->container);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function registerErrorHandler(): void
|
||||||
|
{
|
||||||
|
\Friendica\Core\Logger\Handler\ErrorHandler::register($this->container->create(LoggerInterface::class));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load the whole app instance
|
* Load the whole app instance
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue