mirror of
https://git.friendi.ca/friendica/friendica.git
synced 2025-06-07 18:44:26 +02:00
Implement getAvailableAddons
This commit is contained in:
parent
0599801b37
commit
8b40d65e6c
2 changed files with 38 additions and 1 deletions
|
@ -62,7 +62,33 @@ final class AddonManagerHelper implements AddonHelper
|
|||
*/
|
||||
public function getAvailableAddons(): array
|
||||
{
|
||||
return $this->proxy->getAvailableAddons();
|
||||
$files = glob($this->getAddonPath() . '/*/');
|
||||
|
||||
if (!is_array($files)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$addons = [];
|
||||
|
||||
foreach ($files as $file) {
|
||||
if (!is_dir($file)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$addonId = basename($file);
|
||||
|
||||
$addonInfo = $this->getAddonInfo($addonId);
|
||||
|
||||
if (
|
||||
$this->config->get('system', 'show_unsupported_addons')
|
||||
|| strtolower($addonInfo->getStatus()) !== 'unsupported'
|
||||
|| $this->isAddonEnabled($addonId)
|
||||
) {
|
||||
$addons[] = $addonId;
|
||||
}
|
||||
}
|
||||
|
||||
return $addons;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -98,4 +98,15 @@ class AddonManagerHelperTest extends TestCase
|
|||
|
||||
$this->assertSame(['addonwithadminsettings'], $addonManagerHelper->getEnabledAddonsWithAdminSettings());
|
||||
}
|
||||
|
||||
public function testGetAvailableAddons(): void
|
||||
{
|
||||
$addonManagerHelper = new AddonManagerHelper(
|
||||
__DIR__ . '/../../../Util/addons',
|
||||
$this->createStub(originalClassName: IManageConfigValues::class),
|
||||
$this->createStub(Profiler::class)
|
||||
);
|
||||
|
||||
$this->assertSame(['helloaddon'], $addonManagerHelper->getAvailableAddons());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue