]> git.mxchange.org Git - friendica.git/commitdiff
Create AddonHelper::getEnabledAddonsWithAdminSettings()
authorArt4 <art4@wlabs.de>
Tue, 4 Feb 2025 12:18:08 +0000 (12:18 +0000)
committerArt4 <art4@wlabs.de>
Tue, 4 Feb 2025 12:18:08 +0000 (12:18 +0000)
src/Core/Addon.php
src/Core/Addon/AddonHelper.php
src/Core/Addon/AddonProxy.php
src/Module/Admin/Addons/Details.php

index a922c378f6e5806b020680f9405235956a93c95e..32b832794a7dfe5ff705b42bd73f4e6b50835513 100644 (file)
@@ -66,6 +66,8 @@ class Addon
         * Returns a list of addons that can be configured at the node level.
         * The list is formatted for display in the admin panel aside.
         *
+        * @deprecated 2025.02 Use `Friendica\Core\Addon\AddonHelper::getEnabledAddonsWithAdminSettings()` instead
+        *
         * @return array
         * @throws \Exception
         */
index 63f32a3ae7af6231cdfc72cb4959bd01868e3928..c0b0c0f9c542e4309fd77f3161ea7e0014e94720 100644 (file)
@@ -30,7 +30,7 @@ interface AddonHelper
         *
         * @return bool true on success or false on failure
         */
-       public function installAdodn(string $addonId): bool;
+       public function installAddon(string $addonId): bool;
 
        /**
         * Uninstalls an addon.
@@ -66,5 +66,12 @@ interface AddonHelper
         *
         * @return string[]
         */
-       public static function getVisibleEnabledAddons(): array;
+       public function getVisibleEnabledAddons(): array;
+
+       /**
+        * Returns a list with the IDs of the enabled addons that provides admin settings.
+        *
+        * @return string[]
+        */
+       public function getEnabledAddonsWithAdminSettings(): array;
 }
index ded52e8c293567266c96bac4a3dc9eb0cf1e5139..335505637d3e2c5ab8136c7361b5f64a731dd52b 100644 (file)
@@ -37,7 +37,7 @@ final class AddonProxy implements AddonHelper
         *
         * @return bool true on success or false on failure
         */
-       public function installAdodn(string $addonId): bool
+       public function installAddon(string $addonId): bool
        {
                return Addon::install($addonId);
        }
@@ -96,8 +96,18 @@ final class AddonProxy implements AddonHelper
         *
         * @return string[]
         */
-       public static function getVisibleEnabledAddons(): array
+       public function getVisibleEnabledAddons(): array
        {
                return Addon::getVisibleList();
        }
+
+       /**
+        * Returns a list with the IDs of the enabled addons that provides admin settings.
+        *
+        * @return string[]
+        */
+       public function getEnabledAddonsWithAdminSettings(): array
+       {
+               return array_keys(Addon::getAdminList());
+       }
 }
index 65b51e0ee5e244de36acc4ffe462b476ea4d0aab..12fb71b59e386b0a62c2784f00f710a4eb1603e5 100644 (file)
@@ -8,7 +8,6 @@
 namespace Friendica\Module\Admin\Addons;
 
 use Friendica\Content\Text\Markdown;
-use Friendica\Core\Addon;
 use Friendica\Core\Renderer;
 use Friendica\DI;
 use Friendica\Module\BaseAdmin;
@@ -44,8 +43,6 @@ class Details extends BaseAdmin
 
                $addonHelper = DI::addonHelper();
 
-               $addons_admin = Addon::getAdminList();
-
                $addon = Strings::sanitizeFilePathItem($this->parameters['addon']);
                if (!is_file("addon/$addon/$addon.php")) {
                        DI::sysmsg()->addNotice(DI::l10n()->t('Addon not found.'));
@@ -61,7 +58,7 @@ class Details extends BaseAdmin
                                $addonHelper->uninstallAddon($addon);
                                DI::sysmsg()->addInfo(DI::l10n()->t('Addon %s disabled.', $addon));
                        } else {
-                               $addonHelper->installAdodn($addon);
+                               $addonHelper->installAddon($addon);
                                DI::sysmsg()->addInfo(DI::l10n()->t('Addon %s enabled.', $addon));
                        }
 
@@ -84,8 +81,10 @@ class Details extends BaseAdmin
                        $readme = '<pre>' . file_get_contents("addon/$addon/README") . '</pre>';
                }
 
+               $addons_admin = $addonHelper->getEnabledAddonsWithAdminSettings();
+
                $admin_form = '';
-               if (array_key_exists($addon, $addons_admin)) {
+               if (in_array($addon, $addons_admin)) {
                        require_once "addon/$addon/$addon.php";
                        $func = $addon . '_addon_admin';
                        $func($admin_form);