From 4c71ac643d39e88f3dab657c448f8d35fdf89b57 Mon Sep 17 00:00:00 2001 From: Art4 Date: Tue, 4 Feb 2025 13:13:57 +0000 Subject: [PATCH] Deprecate Addon::DIRECTORY in favor of AddonHelper::getAddonPath() --- src/Core/Addon.php | 3 +++ src/Core/Addon/AddonHelper.php | 7 +++++++ src/Core/Addon/AddonProxy.php | 17 +++++++++++++++++ static/dependencies.config.php | 3 +++ 4 files changed, 30 insertions(+) diff --git a/src/Core/Addon.php b/src/Core/Addon.php index cdf161722f..39a1737946 100644 --- a/src/Core/Addon.php +++ b/src/Core/Addon.php @@ -18,6 +18,9 @@ class Addon { /** * The addon sub-directory + * + * @deprecated 2025.02 Use `Friendica\Core\Addon\AddonHelper::getAddonPath()` instead + * * @var string */ const DIRECTORY = 'addon'; diff --git a/src/Core/Addon/AddonHelper.php b/src/Core/Addon/AddonHelper.php index 0ac2f2ca00..47962692f8 100644 --- a/src/Core/Addon/AddonHelper.php +++ b/src/Core/Addon/AddonHelper.php @@ -14,6 +14,13 @@ namespace Friendica\Core\Addon; */ interface AddonHelper { + /** + * Returns the absolute path to the addon folder + * + * e.g. `/var/www/html/addon` + */ + public function getAddonPath(): string; + /** * Returns the list of available addons with their current status and info. * This list is made from scanning the addon/ folder. diff --git a/src/Core/Addon/AddonProxy.php b/src/Core/Addon/AddonProxy.php index edba8af2f4..360a54ff06 100644 --- a/src/Core/Addon/AddonProxy.php +++ b/src/Core/Addon/AddonProxy.php @@ -18,6 +18,23 @@ use Friendica\Core\Addon; */ final class AddonProxy implements AddonHelper { + private string $addonPath; + + public function __construct(string $addonPath) + { + $this->addonPath = $addonPath; + } + + /** + * Returns the absolute path to the addon folder + * + * e.g. `/var/www/html/addon` + */ + public function getAddonPath(): string + { + return $this->addonPath; + } + /** * Returns the list of available addons with their current status and info. * This list is made from scanning the addon/ folder. diff --git a/static/dependencies.config.php b/static/dependencies.config.php index c41200cb4e..d2de70d208 100644 --- a/static/dependencies.config.php +++ b/static/dependencies.config.php @@ -44,6 +44,9 @@ return (function(string $basepath, array $getVars, array $serverVars, array $coo ], \Friendica\Core\Addon\AddonHelper::class => [ 'instanceOf' => \Friendica\Core\Addon\AddonProxy::class, + 'constructParams' => [ + $basepath . '/addon', + ], ], \Friendica\Util\BasePath::class => [ 'constructParams' => [