use Friendica\App\Mode;
use Friendica\Core\L10n;
use Friendica\Core\Addon as AddonCore;
+use Friendica\Core\Addon\AddonHelper;
use Friendica\Database\Database;
use Friendica\Util\Strings;
use RuntimeException;
* @var Database
*/
private $dba;
+ private AddonHelper $addonHelper;
protected function getHelp()
{
return $help;
}
- public function __construct(Mode $appMode, L10n $l10n, Database $dba, array $argv = null)
+ public function __construct(Mode $appMode, L10n $l10n, Database $dba, AddonHelper $addonHelper, array $argv = null)
{
parent::__construct($argv);
- $this->appMode = $appMode;
- $this->l10n = $l10n;
- $this->dba = $dba;
+ $this->appMode = $appMode;
+ $this->l10n = $l10n;
+ $this->dba = $dba;
+ $this->addonHelper = $addonHelper;
AddonCore::loadAddons();
}
return false;
}
- foreach (AddonCore::getAvailableList() as $addon) {
- $addon_name = $addon[0];
- $enabled = AddonCore::isEnabled($addon_name);
+ foreach ($this->addonHelper->getAvailableAddons() as $addon) {
+ $addonId = $addon[0];
+ $enabled = $this->addonHelper->isAddonEnabled($addonId);
if ($subCmd === 'all') {
- $table->addRow([$addon_name, $enabled ? 'enabled' : 'disabled']);
+ $table->addRow([$addonId, $enabled ? 'enabled' : 'disabled']);
continue;
}
if ($subCmd === 'enabled' && $enabled === true) {
- $table->addRow([$addon_name]);
+ $table->addRow([$addonId]);
continue;
}
if ($subCmd === 'disabled' && $enabled === false) {
- $table->addRow([$addon_name]);
+ $table->addRow([$addonId]);
continue;
}
}
throw new RuntimeException($this->l10n->t('Addon not found'));
}
- if (AddonCore::isEnabled($addon)) {
+ if ($this->addonHelper->isAddonEnabled($addon)) {
throw new RuntimeException($this->l10n->t('Addon already enabled'));
}
throw new RuntimeException($this->l10n->t('Addon not found'));
}
- if (!AddonCore::isEnabled($addon)) {
+ if (!$this->addonHelper->isAddonEnabled($addon)) {
throw new RuntimeException($this->l10n->t('Addon already disabled'));
}
*/
final class AddonProxy implements AddonHelper
{
+ /**
+ * Returns the list of available addons with their current status and info.
+ * This list is made from scanning the addon/ folder.
+ * Unsupported addons are excluded unless they already are enabled or system.show_unsupported_addon is set.
+ *
+ * @return array<array<string|bool|array>>
+ */
+ public function getAvailableAddons(): array
+ {
+ return Addon::getAvailableList();
+ }
+
/**
* Checks if the provided addon is enabled
*/