--- /dev/null
+<?php
+
+// Copyright (C) 2010-2024, the Friendica project
+// SPDX-FileCopyrightText: 2010-2024 the Friendica project
+//
+// SPDX-License-Identifier: AGPL-3.0-or-later
+
+declare(strict_types=1);
+
+namespace Friendica\Core\Addon;
+
+/**
+ * Some functions to handle addons
+ */
+interface AddonHelper
+{
+ /**
+ * Checks if the provided addon is enabled
+ */
+ public function isEnabled(string $addonId): bool;
+}
--- /dev/null
+<?php
+
+// Copyright (C) 2010-2024, the Friendica project
+// SPDX-FileCopyrightText: 2010-2024 the Friendica project
+//
+// SPDX-License-Identifier: AGPL-3.0-or-later
+
+declare(strict_types=1);
+
+namespace Friendica\Core\Addon;
+
+use Friendica\Core\Addon;
+
+/**
+ * Proxy to the Addon class
+ *
+ * @internal
+ */
+final class AddonProxy implements AddonHelper
+{
+ /**
+ * Checks if the provided addon is enabled
+ */
+ public function isEnabled(string $addonId): bool
+ {
+ return Addon::isEnabled($addonId);
+ }
+}
namespace Friendica;
use Dice\Dice;
+use Friendica\Core\Addon\AddonHelper;
use Friendica\Core\Logger\Capability\ICheckLoggerSettings;
use Friendica\Core\Logger\LoggerManager;
use Friendica\Core\Logger\Util\LoggerSettingsCheck;
return self::$dice->create(Core\Storage\Repository\StorageManager::class);
}
+ public static function addonHelper(): AddonHelper
+ {
+ return self::$dice->create(AddonHelper::class);
+ }
+
/**
* @return \Friendica\Core\System
*/
break;
case 'toggle' :
+ $addonHelper = DI::addonHelper();
+
$addon = $_GET['addon'] ?? '';
- if (Addon::isEnabled($addon)) {
+ if ($addonHelper->isEnabled($addon)) {
Addon::uninstall($addon);
DI::sysmsg()->addInfo(DI::l10n()->t('Addon %s disabled.', $addon));
} elseif (Addon::install($addon)) {
[Dice::INSTANCE => Dice::SELF],
],
],
+ \Friendica\Core\Addon\AddonHelper::class => [
+ 'instanceOf' => \Friendica\Core\Addon\AddonProxy::class,
+ ],
\Friendica\Util\BasePath::class => [
'constructParams' => [
$basepath,