mirror of
https://git.friendi.ca/friendica/friendica.git
synced 2025-06-11 22:54:27 +02:00
add support for legacy dependency config files
This commit is contained in:
parent
4fd8caaff7
commit
dc6735eb51
5 changed files with 44 additions and 5 deletions
|
@ -10,7 +10,7 @@ declare(strict_types=1);
|
||||||
namespace Friendica\Service\Addon;
|
namespace Friendica\Service\Addon;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface to community with an addon.
|
* Interface to communicate with an addon.
|
||||||
*/
|
*/
|
||||||
interface Addon
|
interface Addon
|
||||||
{
|
{
|
||||||
|
|
|
@ -46,6 +46,7 @@ final class AddonManager
|
||||||
$dependencyRules = [];
|
$dependencyRules = [];
|
||||||
|
|
||||||
foreach ($this->addons as $addon) {
|
foreach ($this->addons as $addon) {
|
||||||
|
// @TODO At this point we can handle duplicate rules and handle possible conflicts
|
||||||
$dependencyRules = array_merge($dependencyRules, $addon->getProvidedDependencyRules());
|
$dependencyRules = array_merge($dependencyRules, $addon->getProvidedDependencyRules());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,12 @@ final class LegacyAddonProxy implements Addon
|
||||||
|
|
||||||
public function getProvidedDependencyRules(): array
|
public function getProvidedDependencyRules(): array
|
||||||
{
|
{
|
||||||
|
$fileName = $this->path . '/' . $this->name . '/static/dependencies.config.php';
|
||||||
|
|
||||||
|
if (is_file($fileName)) {
|
||||||
|
return include_once($fileName);
|
||||||
|
}
|
||||||
|
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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('<?php return [\'name\' => []];');
|
||||||
|
|
||||||
$addon = new LegacyAddonProxy('helloaddon', $root->url());
|
$addon = new LegacyAddonProxy('helloaddon', $root->url());
|
||||||
|
|
||||||
$this->assertSame(
|
$this->assertSame(
|
||||||
[],
|
['name' => []],
|
||||||
$addon->getProvidedDependencyRules()
|
$addon->getProvidedDependencyRules()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -59,7 +63,6 @@ class LegacyAddonProxyTest extends TestCase
|
||||||
[],
|
[],
|
||||||
$addon->getSubscribedEvents()
|
$addon->getSubscribedEvents()
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testInitAddonIncludesAddonFile(): void
|
public function testInitAddonIncludesAddonFile(): void
|
||||||
|
|
29
tests/Util/helloaddon/static/dependencies.config.php
Normal file
29
tests/Util/helloaddon/static/dependencies.config.php
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @copyright Copyright (C) 2010-2024, the Friendica project
|
||||||
|
*
|
||||||
|
* @license GNU AGPL version 3 or any later version
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
return [
|
||||||
|
\Psr\Log\LoggerInterface::class => [
|
||||||
|
'instanceOf' => \Friendica\Core\Logger\Factory\Logger::class,
|
||||||
|
'call' => null,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue