Replace Addon::DIRECTORY with AddonHelper::getAddonPath()

This commit is contained in:
Art4 2025-02-04 15:18:23 +00:00
parent 4e9276e1c9
commit d8470b68df
11 changed files with 83 additions and 31 deletions

View file

@ -166,6 +166,8 @@ class App
$this->session = $this->container->create(IHandleUserSessions::class);
$this->appHelper = $this->container->create(AppHelper::class);
$addonHelper = $this->container->create(AddonHelper::class);
$this->load(
$request->getServerParams(),
$this->container->create(DbaDefinition::class),
@ -174,6 +176,7 @@ class App
$this->config,
$this->profiler,
$this->appHelper,
$addonHelper,
);
$this->registerTemplateEngine();
@ -182,7 +185,7 @@ class App
$this->container->create(IManagePersonalConfigValues::class),
$this->container->create(Page::class),
$this->container->create(Nav::class),
$this->container->create(AddonHelper::class),
$addonHelper,
$this->container->create(ModuleHTTPException::class),
$start_time,
$request
@ -212,6 +215,7 @@ class App
$this->container->create(IManageConfigValues::class),
$this->container->create(Profiler::class),
$this->container->create(AppHelper::class),
$this->container->create(AddonHelper::class),
);
$this->registerTemplateEngine();
@ -240,6 +244,7 @@ class App
$this->container->create(IManageConfigValues::class),
$this->container->create(Profiler::class),
$this->container->create(AppHelper::class),
$this->container->create(AddonHelper::class),
);
/** @var BasePath */
@ -318,7 +323,8 @@ class App
Mode $mode,
IManageConfigValues $config,
Profiler $profiler,
AppHelper $appHelper
AppHelper $appHelper,
AddonHelper $addonHelper
): void {
if ($config->get('system', 'ini_max_execution_time') !== false) {
set_time_limit((int) $config->get('system', 'ini_max_execution_time'));
@ -340,7 +346,7 @@ class App
if ($mode->has(Mode::DBAVAILABLE)) {
Core\Hook::loadHooks();
$loader = (new Config())->createConfigFileManager($appHelper->getBasePath(), $serverParams);
$loader = (new Config())->createConfigFileManager($appHelper->getBasePath(), $addonHelper->getAddonPath(), $serverParams);
Core\Hook::callAll('load_config', $loader);
// Hooks are now working, reload the whole definitions with hook enabled

View file

@ -42,7 +42,7 @@ class Config
*
* @return Util\ConfigFileManager
*/
public function createConfigFileManager(string $basePath, array $server = []): Util\ConfigFileManager
public function createConfigFileManager(string $basePath, string $addonPath, array $server = []): Util\ConfigFileManager
{
if (!empty($server[self::CONFIG_DIR_ENV]) && is_dir($server[self::CONFIG_DIR_ENV])) {
$configDir = $server[self::CONFIG_DIR_ENV];
@ -51,7 +51,7 @@ class Config
}
$staticDir = $basePath . DIRECTORY_SEPARATOR . self::STATIC_DIR;
return new Util\ConfigFileManager($basePath, $configDir, $staticDir, $server);
return new Util\ConfigFileManager($basePath, $addonPath, $configDir, $staticDir, $server);
}
/**

View file

@ -7,7 +7,6 @@
namespace Friendica\Core\Config\Util;
use Friendica\Core\Addon;
use Friendica\Core\Config\Exception\ConfigFileException;
use Friendica\Core\Config\ValueObject\Cache;
@ -46,6 +45,7 @@ class ConfigFileManager
* @var string
*/
private $baseDir;
private string $addonDir;
/**
* @var string
*/
@ -65,9 +65,10 @@ class ConfigFileManager
* @param string $configDir
* @param string $staticDir
*/
public function __construct(string $baseDir, string $configDir, string $staticDir, array $server = [])
public function __construct(string $baseDir, string $addonDir, string $configDir, string $staticDir, array $server = [])
{
$this->baseDir = $baseDir;
$this->addonDir = $addonDir;
$this->configDir = $configDir;
$this->staticDir = $staticDir;
$this->server = $server;
@ -160,17 +161,16 @@ class ConfigFileManager
*/
public function loadAddonConfig(string $name): array
{
$filepath = $this->baseDir . DIRECTORY_SEPARATOR . // /var/www/html/
Addon::DIRECTORY . DIRECTORY_SEPARATOR . // addon/
$name . DIRECTORY_SEPARATOR . // openstreetmap/
'config' . DIRECTORY_SEPARATOR . // config/
$name . ".config.php"; // openstreetmap.config.php
$filepath = $this->addonDir . DIRECTORY_SEPARATOR . // /var/www/html/addon/
$name . DIRECTORY_SEPARATOR . // openstreetmap/
'config' . DIRECTORY_SEPARATOR . // config/
$name . ".config.php"; // openstreetmap.config.php
if (file_exists($filepath)) {
return $this->loadConfigFile($filepath);
} else {
if (!file_exists($filepath)) {
return [];
}
return $this->loadConfigFile($filepath);
}
/**

View file

@ -26,7 +26,8 @@ class Summary extends BaseAdmin
{
parent::content();
$basePath = DI::appHelper()->getBasePath();
$basePath = DI::appHelper()->getBasePath();
$addonPath = DI::addonHelper()->getAddonPath();
// are there MyISAM tables in the DB? If so, trigger a warning message
$warningtext = [];
@ -117,7 +118,7 @@ class Summary extends BaseAdmin
}
// check legacy basepath settings
$configLoader = (new Config())->createConfigFileManager($basePath, $_SERVER);
$configLoader = (new Config())->createConfigFileManager($basePath, $addonPath, $_SERVER);
$configCache = new Cache();
$configLoader->setupCache($configCache);
$confBasepath = $configCache->get('system', 'basepath');