diff --git a/src/Service/Addon/Addon.php b/src/Service/Addon/Addon.php index f6de695c2b..efbb480916 100644 --- a/src/Service/Addon/Addon.php +++ b/src/Service/Addon/Addon.php @@ -10,7 +10,7 @@ declare(strict_types=1); namespace Friendica\Service\Addon; /** - * Interface to community with an addon. + * Interface to communicate with an addon. */ interface Addon { diff --git a/src/Service/Addon/AddonManager.php b/src/Service/Addon/AddonManager.php index c2e4e7ae68..5988e5e8be 100644 --- a/src/Service/Addon/AddonManager.php +++ b/src/Service/Addon/AddonManager.php @@ -46,6 +46,7 @@ final class AddonManager $dependencyRules = []; foreach ($this->addons as $addon) { + // @TODO At this point we can handle duplicate rules and handle possible conflicts $dependencyRules = array_merge($dependencyRules, $addon->getProvidedDependencyRules()); } diff --git a/src/Service/Addon/LegacyAddonProxy.php b/src/Service/Addon/LegacyAddonProxy.php index 3ece88d2ff..913eff6990 100644 --- a/src/Service/Addon/LegacyAddonProxy.php +++ b/src/Service/Addon/LegacyAddonProxy.php @@ -38,6 +38,12 @@ final class LegacyAddonProxy implements Addon public function getProvidedDependencyRules(): array { + $fileName = $this->path . '/' . $this->name . '/static/dependencies.config.php'; + + if (is_file($fileName)) { + return include_once($fileName); + } + return []; } diff --git a/tests/Unit/Service/Addon/LegacyAddonProxyTest.php b/tests/Unit/Service/Addon/LegacyAddonProxyTest.php index 2daad4d7f3..00e74a01c7 100644 --- a/tests/Unit/Service/Addon/LegacyAddonProxyTest.php +++ b/tests/Unit/Service/Addon/LegacyAddonProxyTest.php @@ -37,14 +37,18 @@ class LegacyAddonProxyTest extends TestCase ); } - public function testGetProvidedDependencyRulesReturnsEmptyArray(): void + public function testGetProvidedDependencyIncludesConfigFile(): void { - $root = vfsStream::setup('addons', 0777, ['helloaddon' => []]); + $root = vfsStream::setup('addons_4', 0777, ['helloaddon' => ['static' => []]]); + + vfsStream::newFile('dependencies.config.php') + ->at($root->getChild('helloaddon/static')) + ->setContent(' []];'); $addon = new LegacyAddonProxy('helloaddon', $root->url()); $this->assertSame( - [], + ['name' => []], $addon->getProvidedDependencyRules() ); } @@ -59,7 +63,6 @@ class LegacyAddonProxyTest extends TestCase [], $addon->getSubscribedEvents() ); - } public function testInitAddonIncludesAddonFile(): void diff --git a/tests/Util/helloaddon/static/dependencies.config.php b/tests/Util/helloaddon/static/dependencies.config.php new file mode 100644 index 0000000000..ca6d549d01 --- /dev/null +++ b/tests/Util/helloaddon/static/dependencies.config.php @@ -0,0 +1,29 @@ +. + * + */ + +return [ + \Psr\Log\LoggerInterface::class => [ + 'instanceOf' => \Friendica\Core\Logger\Factory\Logger::class, + 'call' => null, + ], +]; + +