Refactor getting the basepath

This commit is contained in:
Art4 2024-12-22 16:29:47 +00:00
parent e7e0ae3784
commit 9987c90faf

View file

@ -47,6 +47,12 @@ use Friendica\Network;
use Friendica\Util; use Friendica\Util;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
$basepath = (function() {
$path = dirname(__FILE__, 2);
return ($realpath = realpath($path)) ? $realpath : $path;
})();
return [ return [
'*' => [ '*' => [
// marks all class result as shared for other creations, so there's just // marks all class result as shared for other creations, so there's just
@ -56,7 +62,7 @@ return [
\Friendica\Core\Addon\Capability\ICanLoadAddons::class => [ \Friendica\Core\Addon\Capability\ICanLoadAddons::class => [
'instanceOf' => \Friendica\Core\Addon\Model\AddonLoader::class, 'instanceOf' => \Friendica\Core\Addon\Model\AddonLoader::class,
'constructParams' => [ 'constructParams' => [
[Dice::INSTANCE => '$basepath'], $basepath,
[Dice::INSTANCE => Dice::SELF], [Dice::INSTANCE => Dice::SELF],
], ],
], ],
@ -83,7 +89,7 @@ return [
], ],
\Friendica\Core\Hooks\Util\StrategiesFileManager::class => [ \Friendica\Core\Hooks\Util\StrategiesFileManager::class => [
'constructParams' => [ 'constructParams' => [
[Dice::INSTANCE => '$basepath'], $basepath,
], ],
'call' => [ 'call' => [
['loadConfig'], ['loadConfig'],
@ -108,7 +114,7 @@ return [
'instanceOf' => Config\Factory\Config::class, 'instanceOf' => Config\Factory\Config::class,
'call' => [ 'call' => [
['createConfigFileManager', [ ['createConfigFileManager', [
[Dice::INSTANCE => '$basepath'], $basepath,
$_SERVER, $_SERVER,
], Dice::CHAIN_CALL], ], Dice::CHAIN_CALL],
], ],
@ -123,7 +129,7 @@ return [
'call' => [ 'call' => [
['determineRunMode', [true, $_SERVER], Dice::CHAIN_CALL], ['determineRunMode', [true, $_SERVER], Dice::CHAIN_CALL],
['determine', [ ['determine', [
[Dice::INSTANCE => '$basepath'] $basepath,
], Dice::CHAIN_CALL], ], Dice::CHAIN_CALL],
], ],
], ],
@ -141,7 +147,7 @@ return [
], ],
DbaDefinition::class => [ DbaDefinition::class => [
'constructParams' => [ 'constructParams' => [
[Dice::INSTANCE => '$basepath'], $basepath,
], ],
'call' => [ 'call' => [
['load', [false], Dice::CHAIN_CALL], ['load', [false], Dice::CHAIN_CALL],
@ -149,7 +155,7 @@ return [
], ],
ViewDefinition::class => [ ViewDefinition::class => [
'constructParams' => [ 'constructParams' => [
[Dice::INSTANCE => '$basepath'], $basepath,
], ],
'call' => [ 'call' => [
['load', [false], Dice::CHAIN_CALL], ['load', [false], Dice::CHAIN_CALL],
@ -187,7 +193,7 @@ return [
], ],
App\Page::class => [ App\Page::class => [
'constructParams' => [ 'constructParams' => [
[Dice::INSTANCE => '$basepath'], $basepath,
], ],
], ],
\Psr\Log\LoggerInterface::class => [ \Psr\Log\LoggerInterface::class => [
@ -246,7 +252,7 @@ return [
], ],
\Friendica\Core\System::class => [ \Friendica\Core\System::class => [
'constructParams' => [ 'constructParams' => [
[Dice::INSTANCE => '$basepath'], $basepath,
], ],
], ],
App\Router::class => [ App\Router::class => [