]> git.mxchange.org Git - friendica.git/commitdiff
Create App::fromDice() factory method
authorArt4 <art4@wlabs.de>
Wed, 18 Dec 2024 22:16:34 +0000 (22:16 +0000)
committerArt4 <art4@wlabs.de>
Wed, 18 Dec 2024 22:16:34 +0000 (22:16 +0000)
index.php
src/App.php

index 09620ab4c1d452ea2c7fe0fa684430720eab16ed..d3483cb7cde6e40b9820519ecc97d068d071c038 100644 (file)
--- a/index.php
+++ b/index.php
@@ -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);
 
index d3ff15badaa7c74eb03f0b5f2fc3e35d9f3844b1..2fedaa24e871771fee74d4f5030b5849eaff4172 100644 (file)
@@ -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);
        }