mirror of
https://github.com/friendica/friendica
synced 2025-01-08 19:24:42 +00:00
Merge pull request #14623 from Art4/refactor-entrypoint-auth_ejabberd.php
Refactor entrypoint `auth_ejabberd.php`
This commit is contained in:
commit
5518672677
2 changed files with 44 additions and 42 deletions
|
@ -45,43 +45,13 @@ if (php_sapi_name() !== 'cli') {
|
||||||
}
|
}
|
||||||
|
|
||||||
use Dice\Dice;
|
use Dice\Dice;
|
||||||
use Friendica\App\Mode;
|
|
||||||
use Friendica\Core\Logger\Capability\LogChannel;
|
|
||||||
use Friendica\Security\ExAuth;
|
|
||||||
use Psr\Log\LoggerInterface;
|
|
||||||
|
|
||||||
if (sizeof($_SERVER["argv"]) == 0) {
|
chdir(dirname(__FILE__, 2));
|
||||||
die();
|
|
||||||
}
|
|
||||||
|
|
||||||
$directory = dirname($_SERVER["argv"][0]);
|
require dirname(__FILE__, 2) . '/vendor/autoload.php';
|
||||||
|
|
||||||
if (substr($directory, 0, 1) != DIRECTORY_SEPARATOR) {
|
$dice = (new Dice())->addRules(require(dirname(__FILE__, 2) . '/static/dependencies.config.php'));
|
||||||
$directory = $_SERVER["PWD"] . DIRECTORY_SEPARATOR . $directory;
|
|
||||||
}
|
|
||||||
|
|
||||||
$directory = realpath($directory . DIRECTORY_SEPARATOR . "..");
|
$app = \Friendica\App::fromDice($dice);
|
||||||
|
|
||||||
chdir($directory);
|
$app->processEjabberd();
|
||||||
|
|
||||||
require dirname(__DIR__) . '/vendor/autoload.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(LoggerInterface::class,['constructParams' => [LogChannel::AUTH_JABBERED]]);
|
|
||||||
|
|
||||||
\Friendica\DI::init($dice);
|
|
||||||
\Friendica\Core\Logger\Handler\ErrorHandler::register($dice->create(\Psr\Log\LoggerInterface::class));
|
|
||||||
|
|
||||||
// Check the database structure and possibly fixes it
|
|
||||||
\Friendica\Core\Update::check(\Friendica\DI::basePath(), true);
|
|
||||||
|
|
||||||
$appMode = $dice->create(Mode::class);
|
|
||||||
|
|
||||||
if ($appMode->isNormal()) {
|
|
||||||
/** @var ExAuth $oAuth */
|
|
||||||
$oAuth = $dice->create(ExAuth::class);
|
|
||||||
$oAuth->readStdin();
|
|
||||||
}
|
|
||||||
|
|
46
src/App.php
46
src/App.php
|
@ -23,12 +23,14 @@ use Friendica\Database\Definition\ViewDefinition;
|
||||||
use Friendica\Module\Maintenance;
|
use Friendica\Module\Maintenance;
|
||||||
use Friendica\Security\Authentication;
|
use Friendica\Security\Authentication;
|
||||||
use Friendica\Core\Config\Capability\IManageConfigValues;
|
use Friendica\Core\Config\Capability\IManageConfigValues;
|
||||||
|
use Friendica\Core\Logger\Capability\LogChannel;
|
||||||
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
|
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
use Friendica\Module\Special\HTTPException as ModuleHTTPException;
|
use Friendica\Module\Special\HTTPException as ModuleHTTPException;
|
||||||
use Friendica\Network\HTTPException;
|
use Friendica\Network\HTTPException;
|
||||||
use Friendica\Protocol\ATProtocol\DID;
|
use Friendica\Protocol\ATProtocol\DID;
|
||||||
|
use Friendica\Security\ExAuth;
|
||||||
use Friendica\Security\OpenWebAuth;
|
use Friendica\Security\OpenWebAuth;
|
||||||
use Friendica\Util\DateTimeFormat;
|
use Friendica\Util\DateTimeFormat;
|
||||||
use Friendica\Util\HTTPInputData;
|
use Friendica\Util\HTTPInputData;
|
||||||
|
@ -121,7 +123,15 @@ class App
|
||||||
|
|
||||||
public function processRequest(ServerRequestInterface $request, float $start_time): void
|
public function processRequest(ServerRequestInterface $request, float $start_time): void
|
||||||
{
|
{
|
||||||
$this->setupContainerForRunningFrontend($request);
|
$this->setupContainerForAddons();
|
||||||
|
|
||||||
|
$this->container = $this->container->addRule(Mode::class, [
|
||||||
|
'call' => [
|
||||||
|
['determineRunMode', [false, $request->getServerParams()], Dice::CHAIN_CALL],
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->setupLegacyServiceLocator();
|
||||||
|
|
||||||
$this->registerErrorHandler();
|
$this->registerErrorHandler();
|
||||||
|
|
||||||
|
@ -156,18 +166,40 @@ class App
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function setupContainerForRunningFrontend(ServerRequestInterface $request): void
|
public function processEjabberd(): void
|
||||||
|
{
|
||||||
|
$this->setupContainerForAddons();
|
||||||
|
|
||||||
|
$this->container = $this->container->addRule(LoggerInterface::class,[
|
||||||
|
'constructParams' => [LogChannel::AUTH_JABBERED],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->setupLegacyServiceLocator();
|
||||||
|
|
||||||
|
$this->registerErrorHandler();
|
||||||
|
|
||||||
|
// Check the database structure and possibly fixes it
|
||||||
|
\Friendica\Core\Update::check(\Friendica\DI::basePath(), true);
|
||||||
|
|
||||||
|
$appMode = $this->container->create(Mode::class);
|
||||||
|
|
||||||
|
if ($appMode->isNormal()) {
|
||||||
|
/** @var ExAuth $oAuth */
|
||||||
|
$oAuth = $this->container->create(ExAuth::class);
|
||||||
|
$oAuth->readStdin();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function setupContainerForAddons(): void
|
||||||
{
|
{
|
||||||
/** @var \Friendica\Core\Addon\Capability\ICanLoadAddons $addonLoader */
|
/** @var \Friendica\Core\Addon\Capability\ICanLoadAddons $addonLoader */
|
||||||
$addonLoader = $this->container->create(\Friendica\Core\Addon\Capability\ICanLoadAddons::class);
|
$addonLoader = $this->container->create(\Friendica\Core\Addon\Capability\ICanLoadAddons::class);
|
||||||
|
|
||||||
$this->container = $this->container->addRules($addonLoader->getActiveAddonConfig('dependencies'));
|
$this->container = $this->container->addRules($addonLoader->getActiveAddonConfig('dependencies'));
|
||||||
$this->container = $this->container->addRule(Mode::class, [
|
}
|
||||||
'call' => [
|
|
||||||
['determineRunMode', [false, $request->getServerParams()], Dice::CHAIN_CALL],
|
|
||||||
],
|
|
||||||
]);
|
|
||||||
|
|
||||||
|
private function setupLegacyServiceLocator(): void
|
||||||
|
{
|
||||||
\Friendica\DI::init($this->container);
|
\Friendica\DI::init($this->container);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue