]> git.mxchange.org Git - friendica.git/commitdiff
replace calls for App::getBasePath() with AppHelper
authorArt4 <art4@wlabs.de>
Sun, 10 Nov 2024 10:57:13 +0000 (10:57 +0000)
committerArt4 <art4@wlabs.de>
Sun, 10 Nov 2024 10:57:13 +0000 (10:57 +0000)
src/Console/DocBloxErrorChecker.php
src/Console/PostUpdate.php
src/Core/Hook.php
src/Module/Admin/Summary.php
src/Module/Home.php
src/Worker/Cron.php
src/Worker/DBUpdate.php

index 2b16b6694b72488823afb27264d013d2fd06a2f5..694940c95e67796e84c8e3c256b2e385333ab975 100644 (file)
@@ -7,7 +7,7 @@
 
 namespace Friendica\Console;
 
-use Friendica\App;
+use Friendica\AppHelper;
 
 /**
  * When I installed docblox, I had the experience that it does not generate any output at all.
@@ -33,14 +33,14 @@ class DocBloxErrorChecker extends \Asika\SimpleConsole\Console
 
        protected $helpOptions = ['h', 'help', '?'];
 
-       /** @var App */
-       private $app;
+       /** @var string */
+       private $basePath;
 
-       public function __construct(App $app, array $argv = null)
+       public function __construct(AppHelper $appHelper, array $argv = null)
        {
                parent::__construct($argv);
 
-               $this->app = $app;
+               $this->basePath = $appHelper->getBasePath();
        }
 
        protected function getHelp()
@@ -73,7 +73,7 @@ HELP;
                        throw new \RuntimeException('DocBlox isn\'t available.');
                }
 
-               $dir = $this->app->getBasePath();
+               $dir = $this->basePath;
 
                //stack for dirs to search
                $dirstack = [];
index 90c75bb34313d537a3fd0e4d18e3abcb5520e6ec..2d0357a460f7a6848308cf4809ae402097c8fb84 100644 (file)
@@ -7,10 +7,11 @@
 
 namespace Friendica\Console;
 
-use Friendica\App;
+use Friendica\App\Mode;
 use Friendica\Core\KeyValueStorage\Capability\IManageKeyValuePairs;
 use Friendica\Core\L10n;
 use Friendica\Core\Update;
+use Friendica\DI;
 
 /**
  * Performs database post updates
@@ -20,7 +21,7 @@ class PostUpdate extends \Asika\SimpleConsole\Console
        protected $helpOptions = ['h', 'help', '?'];
 
        /**
-        * @var App\Mode
+        * @var Mode
         */
        private $appMode;
        /**
@@ -31,6 +32,10 @@ class PostUpdate extends \Asika\SimpleConsole\Console
         * @var L10n
         */
        private $l10n;
+       /**
+        * @var string
+        */
+       private $basePath;
 
        protected function getHelp()
        {
@@ -46,19 +51,18 @@ HELP;
                return $help;
        }
 
-       public function __construct(App\Mode $appMode, IManageKeyValuePairs $keyValue, L10n $l10n, array $argv = null)
+       public function __construct(Mode $appMode, IManageKeyValuePairs $keyValue, L10n $l10n, array $argv = null)
        {
                parent::__construct($argv);
 
                $this->appMode  = $appMode;
                $this->keyValue = $keyValue;
                $this->l10n     = $l10n;
+               $this->basePath = DI::apphelper()->getBasePath();
        }
 
        protected function doExecute(): int
        {
-               $a = \Friendica\DI::app();
-
                if ($this->getOption($this->helpOptions)) {
                        $this->out($this->getHelp());
                        return 0;
@@ -79,7 +83,7 @@ HELP;
                }
 
                echo $this->l10n->t('Check for pending update actions.') . "\n";
-               Update::run($a->getBasePath(), true, false, true, false);
+               Update::run($this->basePath, true, false, true, false);
                echo $this->l10n->t('Done.') . "\n";
 
                echo $this->l10n->t('Execute pending post updates.') . "\n";
index 74256b11ec1d981c71332fe82f1fed062515eedd..c3c994a31437322271fb9d04de81fd0b45acae24 100644 (file)
@@ -81,7 +81,7 @@ class Hook
         */
        public static function register(string $hook, string $file, string $function, int $priority = 0)
        {
-               $file = str_replace(DI::app()->getBasePath() . DIRECTORY_SEPARATOR, '', $file);
+               $file = str_replace(DI::apphelper()->getBasePath() . DIRECTORY_SEPARATOR, '', $file);
 
                $condition = ['hook' => $hook, 'file' => $file, 'function' => $function];
                if (DBA::exists('hook', $condition)) {
@@ -102,7 +102,7 @@ class Hook
         */
        public static function unregister(string $hook, string $file, string $function): bool
        {
-               $relative_file = str_replace(DI::app()->getBasePath() . DIRECTORY_SEPARATOR, '', $file);
+               $relative_file = str_replace(DI::apphelper()->getBasePath() . DIRECTORY_SEPARATOR, '', $file);
 
                // This here is only needed for fixing a problem that existed on the develop branch
                $condition = ['hook' => $hook, 'file' => $file, 'function' => $function];
@@ -198,7 +198,7 @@ class Hook
        public static function callSingle(string $name, array $hook, &$data = null)
        {
                // Don't run a theme's hook if the user isn't using the theme
-               if (strpos($hook[0], 'view/theme/') !== false && strpos($hook[0], 'view/theme/' . DI::app()->getCurrentTheme()) === false) {
+               if (strpos($hook[0], 'view/theme/') !== false && strpos($hook[0], 'view/theme/' . DI::apphelper()->getCurrentTheme()) === false) {
                        return;
                }
 
index 16e376faf17a386ef26d58ebc6e7ed6d9ee3357f..04980f55bfe8ffc45f0d08f517511a45729f3e72 100644 (file)
@@ -29,7 +29,7 @@ class Summary extends BaseAdmin
        {
                parent::content();
 
-               $a = DI::app();
+               $basePath = DI::apphelper()->getBasePath();
 
                // are there MyISAM tables in the DB? If so, trigger a warning message
                $warningtext = [];
@@ -120,7 +120,7 @@ class Summary extends BaseAdmin
                }
 
                // check legacy basepath settings
-               $configLoader = (new Config())->createConfigFileManager($a->getBasePath(), $_SERVER);
+               $configLoader = (new Config())->createConfigFileManager($basePath, $_SERVER);
                $configCache = new Cache();
                $configLoader->setupCache($configCache);
                $confBasepath = $configCache->get('system', 'basepath');
index 2d79148c587b1a52b5a3699b7b2d9fa7d49269e6..94cb08773ec52976314bfdac85664923f8eefb9b 100644 (file)
@@ -32,7 +32,7 @@ class Home extends BaseModule
 
        protected function content(array $request = []): string
        {
-               $app = DI::app();
+               $basePath = DI::apphelper()->getBasePath();
                $config = DI::config();
 
                // currently no returned data is used
@@ -51,8 +51,8 @@ class Home extends BaseModule
                $customHome = '';
                $defaultHeader = ($config->get('config', 'sitename') ? DI::l10n()->t('Welcome to %s', $config->get('config', 'sitename')) : '');
 
-               $homeFilePath = $app->getBasePath() . '/home.html';
-               $cssFilePath = $app->getBasePath() . '/home.css';
+               $homeFilePath = $basePath . '/home.html';
+               $cssFilePath = $basePath . '/home.css';
 
                if (file_exists($homeFilePath)) {
                        $customHome = $homeFilePath;
index 1c21bf50650d82387864ddf3886a09c331122435..e6d11db3704cc5dbd92b4f9491789ba7b3d5db08 100644 (file)
@@ -21,7 +21,7 @@ class Cron
 {
        public static function execute()
        {
-               $a = DI::app();
+               $basepath = DI::apphelper()->getBasePath();
 
                $last = DI::keyValue()->get('last_cron');
 
@@ -39,7 +39,6 @@ class Cron
 
                // Ensure to have a .htaccess file.
                // this is a precaution for systems that update automatically
-               $basepath = $a->getBasePath();
                if (!file_exists($basepath . '/.htaccess') && is_writable($basepath)) {
                        copy($basepath . '/.htaccess-dist', $basepath . '/.htaccess');
                }
index cea9df49c02245e62a91309cb7b0753c9e1aeec4..87a3fae27fea4299bd8666aa8c3b1fcaf23b7198 100644 (file)
@@ -19,7 +19,7 @@ class DBUpdate
        {
                // Just in case the last update wasn't failed
                if (DI::config()->get('system', 'update', Update::SUCCESS) != Update::FAILED) {
-                       Update::run(DI::app()->getBasePath());
+                       Update::run(DI::apphelper()->getBasePath());
                }
        }
 }