mirror of
https://git.friendi.ca/friendica/friendica.git
synced 2025-06-17 16:05:14 +02:00
Implement getAddonDependencyConfig
This commit is contained in:
parent
638496e553
commit
694893e2bb
3 changed files with 113 additions and 0 deletions
|
@ -9,6 +9,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace Friendica\Core\Addon;
|
||||
|
||||
use Friendica\Core\Addon\Exception\AddonInvalidConfigFileException;
|
||||
use Friendica\Core\Cache\Capability\ICanCache;
|
||||
use Friendica\Core\Config\Capability\IManageConfigValues;
|
||||
use Friendica\Database\Database;
|
||||
|
@ -246,6 +247,34 @@ final class AddonManagerHelper implements AddonHelper
|
|||
return AddonInfo::fromString($addonId, $raw);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a dependency config array for a given addon
|
||||
*
|
||||
* This will load a potential config-file from the static directory, like `addon/{addonId}/static/dependencies.config.php`
|
||||
*
|
||||
* @throws AddonInvalidConfigFileException If the config file doesn't return an array
|
||||
*
|
||||
* @return array the config as array or empty array if no config file was found
|
||||
*/
|
||||
public function getAddonDependencyConfig(string $addonId): array
|
||||
{
|
||||
$addonId = Strings::sanitizeFilePathItem(trim($addonId));
|
||||
|
||||
$configFile = $this->getAddonPath() . '/' . $addonId . '/static/dependencies.config.php';
|
||||
|
||||
if (!file_exists($configFile)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$config = include($configFile);
|
||||
|
||||
if (!is_array($config)) {
|
||||
throw new AddonInvalidConfigFileException('Error loading config file ' . $configFile);
|
||||
}
|
||||
|
||||
return $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the provided addon is enabled
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue