mirror of
https://github.com/friendica/friendica
synced 2024-12-22 12:00:17 +00:00
Create App::fromDice() factory method
This commit is contained in:
parent
23b19b76b5
commit
1c7446bf9a
2 changed files with 24 additions and 3 deletions
|
@ -25,7 +25,7 @@ $dice = $dice->addRule(Friendica\App\Mode::class, ['call' => [['determineRunMode
|
|||
|
||||
\Friendica\Core\Logger\Handler\ErrorHandler::register($dice->create(\Psr\Log\LoggerInterface::class));
|
||||
|
||||
$a = \Friendica\DI::app();
|
||||
$a = \Friendica\App::fromDice($dice);
|
||||
|
||||
\Friendica\DI::mode()->setExecutor(\Friendica\App\Mode::INDEX);
|
||||
|
||||
|
|
25
src/App.php
25
src/App.php
|
@ -7,6 +7,7 @@
|
|||
|
||||
namespace Friendica;
|
||||
|
||||
use Dice\Dice;
|
||||
use Friendica\App\Arguments;
|
||||
use Friendica\App\BaseURL;
|
||||
use Friendica\App\Mode;
|
||||
|
@ -51,6 +52,25 @@ class App
|
|||
const CODENAME = 'Yellow Archangel';
|
||||
const VERSION = '2024.12-dev';
|
||||
|
||||
public static function fromDice(Dice $dice): self
|
||||
{
|
||||
return new self(
|
||||
$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(DbaDefinition::class),
|
||||
$dice->create(ViewDefinition::class),
|
||||
$dice->create(AppHelper::class)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @var Mode The Mode of the Application
|
||||
*/
|
||||
|
@ -114,7 +134,8 @@ class App
|
|||
Arguments $args,
|
||||
IHandleUserSessions $session,
|
||||
DbaDefinition $dbaDefinition,
|
||||
ViewDefinition $viewDefinition
|
||||
ViewDefinition $viewDefinition,
|
||||
AppHelper $appHelper = null,
|
||||
) {
|
||||
$this->requestId = $request->getRequestId();
|
||||
$this->auth = $auth;
|
||||
|
@ -126,7 +147,7 @@ class App
|
|||
$this->l10n = $l10n;
|
||||
$this->args = $args;
|
||||
$this->session = $session;
|
||||
$this->appHelper = DI::appHelper();
|
||||
$this->appHelper = $appHelper ?? DI::appHelper();
|
||||
|
||||
$this->load($dbaDefinition, $viewDefinition);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue