]> git.mxchange.org Git - friendica.git/commitdiff
Move creation of Dice into Container class
authorArt4 <art4@wlabs.de>
Wed, 8 Jan 2025 22:35:27 +0000 (22:35 +0000)
committerArt4 <art4@wlabs.de>
Wed, 8 Jan 2025 22:35:27 +0000 (22:35 +0000)
bin/auth_ejabberd.php
bin/console.php
bin/daemon.php
bin/jetstream.php
bin/worker.php
index.php
src/Core/Container.php

index 68ee53a8b0d0a4052348b8660a50b80968aaf732..7a279b079bf0b73571c4eb9a27b7f215b546d56d 100755 (executable)
@@ -44,15 +44,12 @@ if (php_sapi_name() !== 'cli') {
        exit();
 }
 
-use Dice\Dice;
+chdir(dirname(__DIR__));
 
-chdir(dirname(__FILE__, 2));
+require dirname(__DIR__) . '/vendor/autoload.php';
 
-require dirname(__FILE__, 2) . '/vendor/autoload.php';
+$container = \Friendica\Core\Container::fromBasePath(dirname(__DIR__));
 
-$dice = (new Dice())->addRules(require(dirname(__FILE__, 2) . '/static/dependencies.config.php'));
-
-$container = \Friendica\Core\Container::fromDice($dice);
-$app       = \Friendica\App::fromContainer($container);
+$app = \Friendica\App::fromContainer($container);
 
 $app->processEjabberd();
index 404f327868549869becf66316dd2fd3f547e7759..94738dbf8cc4bbccabed0856db495fa6f7d91311 100755 (executable)
@@ -13,13 +13,9 @@ if (php_sapi_name() !== 'cli') {
        exit();
 }
 
-use Dice\Dice;
-
 require dirname(__DIR__) . '/vendor/autoload.php';
 
-$dice = (new Dice())->addRules(require(dirname(__DIR__) . '/static/dependencies.config.php'));
-
-$container = \Friendica\Core\Container::fromDice($dice);
+$container = \Friendica\Core\Container::fromBasePath(dirname(__DIR__));
 
 $app = \Friendica\App::fromContainer($container);
 
index a1c0abbfaf9de6b4eee4bbeafda044ab23ecbafb..04e00ccf0d21b27576ed8e603594e60a6ff94dce 100755 (executable)
@@ -19,19 +19,15 @@ if (php_sapi_name() !== 'cli') {
        exit();
 }
 
-use Dice\Dice;
-
 // Ensure that daemon.php is executed from the base path of the installation
 chdir(dirname(__DIR__));
 
 require dirname(__DIR__) . '/vendor/autoload.php';
 
-$dice = (new Dice())->addRules(require(dirname(__DIR__) . '/static/dependencies.config.php'));
-
 $argv = $_SERVER['argv'] ?? [];
 array_splice($argv, 1, 0, "daemon");
 
-$container = \Friendica\Core\Container::fromDice($dice);
+$container = \Friendica\Core\Container::fromBasePath(dirname(__DIR__));
 
 $app = \Friendica\App::fromContainer($container);
 
index ac33e8ff2aae8b0948e263f98f6b881fbf8e9ad4..72d13c3e1fbe7be10f5d161a127fc8333bb7d37c 100755 (executable)
@@ -9,8 +9,6 @@
  * @deprecated 2025.02 use bin/console.php jetstream instead
  */
 
-use Dice\Dice;
-
 if (php_sapi_name() !== 'cli') {
        header($_SERVER["SERVER_PROTOCOL"] . ' 403 Forbidden');
        exit();
@@ -21,12 +19,10 @@ chdir(dirname(__DIR__));
 
 require dirname(__DIR__) . '/vendor/autoload.php';
 
-$dice = (new Dice())->addRules(require(dirname(__DIR__) . '/static/dependencies.config.php'));
-
 $argv = $_SERVER['argv'] ?? [];
 array_splice($argv, 1, 0, "jetstream");
 
-$container = \Friendica\Core\Container::fromDice($dice);
+$container = \Friendica\Core\Container::fromBasePath(dirname(__DIR__));
 
 $app = \Friendica\App::fromContainer($container);
 
index fa238b66a292c7e344a9c354cfc3b4aa18231413..54b36e392fcf1c782bc59dbc746f2602062ec81e 100755 (executable)
@@ -16,19 +16,15 @@ if (php_sapi_name() !== 'cli') {
        exit();
 }
 
-use Dice\Dice;
-
 // Ensure that worker.php is executed from the base path of the installation
 chdir(dirname(__DIR__));
 
 require dirname(__DIR__) . '/vendor/autoload.php';
 
-$dice = (new Dice())->addRules(require(dirname(__DIR__) . '/static/dependencies.config.php'));
-
 $argv = $_SERVER['argv'] ?? [];
 array_splice($argv, 1, 0, "worker");
 
-$container = \Friendica\Core\Container::fromDice($dice);
+$container = \Friendica\Core\Container::fromBasePath(dirname(__DIR__));
 
 $app = \Friendica\App::fromContainer($container);
 
index 6654dcb515d02909ee3d4a8cf480df0ea503b6ca..906d91bc3c7ee2250b9c88aff06de1975dd02c32 100644 (file)
--- a/index.php
+++ b/index.php
@@ -5,8 +5,6 @@
 //
 // SPDX-License-Identifier: AGPL-3.0-or-later
 
-use Dice\Dice;
-
 $start_time = microtime(true);
 
 if (!file_exists(__DIR__ . '/vendor/autoload.php')) {
@@ -17,9 +15,7 @@ require __DIR__ . '/vendor/autoload.php';
 
 $request = \GuzzleHttp\Psr7\ServerRequest::fromGlobals();
 
-$dice = (new Dice())->addRules(require(__DIR__ . '/static/dependencies.config.php'));
-
-$container = \Friendica\Core\Container::fromDice($dice);
+$container = \Friendica\Core\Container::fromBasePath(__DIR__);
 $app       = \Friendica\App::fromContainer($container);
 
 $app->processRequest($request, $start_time);
index 12a9b625a75265e71ee1cc9a85cb2e697ec6cbef..0da94935d8ad2727d40fe17d1cbae74d4b81cfd5 100644 (file)
@@ -21,9 +21,18 @@ use Psr\Log\LoggerInterface;
  */
 class Container
 {
+       public static function fromBasePath(string $basePath): self
+       {
+               $path = $basePath . '/static/dependencies.config.php';
+
+               $dice = (new Dice())->addRules(require($path));
+
+               return static::fromDice($dice);
+       }
+
        private Dice $container;
 
-       protected function __construct(Dice $container)
+       private function __construct(Dice $container)
        {
                $this->container = $container;
        }