mirror of
https://github.com/friendica/friendica
synced 2025-02-19 07:26:48 +00:00
Implement AddonHelper::loadAddons()
This commit is contained in:
parent
5497fd3559
commit
e596a0b624
9 changed files with 56 additions and 30 deletions
11
src/App.php
11
src/App.php
|
@ -17,6 +17,7 @@ use Friendica\App\Router;
|
|||
use Friendica\Capabilities\ICanCreateResponses;
|
||||
use Friendica\Capabilities\ICanHandleRequests;
|
||||
use Friendica\Content\Nav;
|
||||
use Friendica\Core\Addon\AddonHelper;
|
||||
use Friendica\Core\Addon\Capability\ICanLoadAddons;
|
||||
use Friendica\Core\Config\Factory\Config;
|
||||
use Friendica\Core\Container;
|
||||
|
@ -181,6 +182,7 @@ class App
|
|||
$this->container->create(IManagePersonalConfigValues::class),
|
||||
$this->container->create(Page::class),
|
||||
$this->container->create(Nav::class),
|
||||
$this->container->create(AddonHelper::class),
|
||||
$this->container->create(ModuleHTTPException::class),
|
||||
$start_time,
|
||||
$request
|
||||
|
@ -388,6 +390,7 @@ class App
|
|||
IManagePersonalConfigValues $pconfig,
|
||||
Page $page,
|
||||
Nav $nav,
|
||||
AddonHelper $addonHelper,
|
||||
ModuleHTTPException $httpException,
|
||||
float $start_time,
|
||||
ServerRequestInterface $request
|
||||
|
@ -475,12 +478,12 @@ class App
|
|||
// but we need "view" module for stylesheet
|
||||
if ($this->mode->isInstall() && $moduleName !== 'install') {
|
||||
$this->baseURL->redirect('install');
|
||||
} else {
|
||||
Core\Update::check($this->appHelper->getBasePath(), false);
|
||||
Core\Addon::loadAddons();
|
||||
Core\Hook::loadHooks();
|
||||
}
|
||||
|
||||
Core\Update::check($this->appHelper->getBasePath(), false);
|
||||
$addonHelper->loadAddons();
|
||||
Core\Hook::loadHooks();
|
||||
|
||||
// Compatibility with Hubzilla
|
||||
if ($moduleName == 'rpost') {
|
||||
$this->baseURL->redirect('compose');
|
||||
|
|
|
@ -10,7 +10,6 @@ namespace Friendica\Console;
|
|||
use Console_Table;
|
||||
use Friendica\App\Mode;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Addon as AddonCore;
|
||||
use Friendica\Core\Addon\AddonHelper;
|
||||
use Friendica\Database\Database;
|
||||
use Friendica\Util\Strings;
|
||||
|
@ -67,7 +66,7 @@ HELP;
|
|||
$this->dba = $dba;
|
||||
$this->addonHelper = $addonHelper;
|
||||
|
||||
AddonCore::loadAddons();
|
||||
$this->addonHelper->loadAddons();
|
||||
}
|
||||
|
||||
protected function doExecute(): int
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace Friendica\Console;
|
|||
|
||||
use Asika\SimpleConsole\Console;
|
||||
use Friendica\App\Mode;
|
||||
use Friendica\Core\Addon;
|
||||
use Friendica\Core\Addon\AddonHelper;
|
||||
use Friendica\Core\Config\Capability\IManageConfigValues;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\KeyValueStorage\Capability\IManageKeyValuePairs;
|
||||
|
@ -29,6 +29,7 @@ final class JetstreamDaemon extends Console
|
|||
private IManageKeyValuePairs $keyValue;
|
||||
private SysDaemon $daemon;
|
||||
private Jetstream $jetstream;
|
||||
private AddonHelper $addonHelper;
|
||||
|
||||
/**
|
||||
* @param Mode $mode
|
||||
|
@ -38,15 +39,16 @@ final class JetstreamDaemon extends Console
|
|||
* @param Jetstream $jetstream
|
||||
* @param array|null $argv
|
||||
*/
|
||||
public function __construct(Mode $mode, IManageConfigValues $config, IManageKeyValuePairs $keyValue, SysDaemon $daemon, Jetstream $jetstream, array $argv = null)
|
||||
public function __construct(Mode $mode, IManageConfigValues $config, IManageKeyValuePairs $keyValue, SysDaemon $daemon, Jetstream $jetstream, AddonHelper $addonHelper, array $argv = null)
|
||||
{
|
||||
parent::__construct($argv);
|
||||
|
||||
$this->mode = $mode;
|
||||
$this->config = $config;
|
||||
$this->keyValue = $keyValue;
|
||||
$this->jetstream = $jetstream;
|
||||
$this->daemon = $daemon;
|
||||
$this->mode = $mode;
|
||||
$this->config = $config;
|
||||
$this->keyValue = $keyValue;
|
||||
$this->jetstream = $jetstream;
|
||||
$this->daemon = $daemon;
|
||||
$this->addonHelper = $addonHelper;
|
||||
}
|
||||
|
||||
protected function getHelp(): string
|
||||
|
@ -95,10 +97,10 @@ HELP;
|
|||
);
|
||||
}
|
||||
|
||||
Addon::loadAddons();
|
||||
$this->addonHelper->loadAddons();
|
||||
Hook::loadHooks();
|
||||
|
||||
if (!Addon::isEnabled('bluesky')) {
|
||||
if (!$this->addonHelper->isAddonEnabled('bluesky')) {
|
||||
throw new RuntimeException("Bluesky has to be enabled.\n");
|
||||
}
|
||||
|
||||
|
|
|
@ -87,19 +87,21 @@ class Widget
|
|||
*/
|
||||
public static function unavailableNetworks(): array
|
||||
{
|
||||
$addonHelper = DI::addonHelper();
|
||||
|
||||
// Always hide content from these networks
|
||||
$networks = [Protocol::PHANTOM, Protocol::FACEBOOK, Protocol::APPNET, Protocol::TWITTER, Protocol::ZOT, Protocol::OSTATUS, Protocol::STATUSNET];
|
||||
Addon::loadAddons();
|
||||
$addonHelper->loadAddons();
|
||||
|
||||
if (!Addon::isEnabled('discourse')) {
|
||||
if (!$addonHelper->isAddonEnabled('discourse')) {
|
||||
$networks[] = Protocol::DISCOURSE;
|
||||
}
|
||||
|
||||
if (!Addon::isEnabled('pumpio')) {
|
||||
if (!$addonHelper->isAddonEnabled('pumpio')) {
|
||||
$networks[] = Protocol::PUMPIO;
|
||||
}
|
||||
|
||||
if (!Addon::isEnabled('tumblr')) {
|
||||
if (!$addonHelper->isAddonEnabled('tumblr')) {
|
||||
$networks[] = Protocol::TUMBLR;
|
||||
}
|
||||
|
||||
|
@ -107,7 +109,7 @@ class Widget
|
|||
$networks[] = Protocol::DIASPORA;
|
||||
}
|
||||
|
||||
if (!Addon::isEnabled('pnut')) {
|
||||
if (!$addonHelper->isAddonEnabled('pnut')) {
|
||||
$networks[] = Protocol::PNUT;
|
||||
}
|
||||
return $networks;
|
||||
|
@ -120,18 +122,20 @@ class Widget
|
|||
*/
|
||||
public static function availableNetworks(): array
|
||||
{
|
||||
$networks = [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::FEED];
|
||||
Addon::loadAddons();
|
||||
$addonHelper = DI::addonHelper();
|
||||
|
||||
if (Addon::isEnabled('discourse')) {
|
||||
$networks = [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::FEED];
|
||||
$addonHelper->loadAddons();
|
||||
|
||||
if ($addonHelper->isAddonEnabled('discourse')) {
|
||||
$networks[] = Protocol::DISCOURSE;
|
||||
}
|
||||
|
||||
if (Addon::isEnabled('pumpio')) {
|
||||
if ($addonHelper->isAddonEnabled('pumpio')) {
|
||||
$networks[] = Protocol::PUMPIO;
|
||||
}
|
||||
|
||||
if (Addon::isEnabled('tumblr')) {
|
||||
if ($addonHelper->isAddonEnabled('tumblr')) {
|
||||
$networks[] = Protocol::TUMBLR;
|
||||
}
|
||||
|
||||
|
@ -143,7 +147,7 @@ class Widget
|
|||
$networks[] = Protocol::MAIL;
|
||||
}
|
||||
|
||||
if (Addon::isEnabled('pnut')) {
|
||||
if ($addonHelper->isAddonEnabled('pnut')) {
|
||||
$networks[] = Protocol::PNUT;
|
||||
}
|
||||
return $networks;
|
||||
|
|
|
@ -92,7 +92,6 @@ class Addon
|
|||
return $addons_admin;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Synchronize addons:
|
||||
*
|
||||
|
@ -104,6 +103,7 @@ class Addon
|
|||
* Then go through the config list and if we have a addon that isn't installed,
|
||||
* call the install procedure and add it to the database.
|
||||
*
|
||||
* @deprecated 2025.02 Use `Friendica\Core\Addon\AddonHelper::loadAddons()` instead
|
||||
*/
|
||||
public static function loadAddons()
|
||||
{
|
||||
|
|
|
@ -39,6 +39,13 @@ interface AddonHelper
|
|||
*/
|
||||
public function uninstallAddon(string $addonId): void;
|
||||
|
||||
/**
|
||||
* Load addons.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
public function loadAddons(): void;
|
||||
|
||||
/**
|
||||
* Reload (uninstall and install) all updated addons.
|
||||
*/
|
||||
|
|
|
@ -52,6 +52,16 @@ final class AddonProxy implements AddonHelper
|
|||
Addon::uninstall($addonId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load addons.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
public function loadAddons(): void
|
||||
{
|
||||
Addon::loadAddons();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reload (uninstall and install) all updated addons.
|
||||
*/
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
namespace Friendica\Core\Storage\Repository;
|
||||
|
||||
use Exception;
|
||||
use Friendica\Core\Addon;
|
||||
use Friendica\Core\Config\Capability\IManageConfigValues;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\L10n;
|
||||
|
@ -20,6 +19,7 @@ use Friendica\Core\Storage\Capability\ICanConfigureStorage;
|
|||
use Friendica\Core\Storage\Capability\ICanWriteToStorage;
|
||||
use Friendica\Database\Database;
|
||||
use Friendica\Core\Storage\Type;
|
||||
use Friendica\DI;
|
||||
use Friendica\Network\HTTPException\InternalServerErrorException;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
|
@ -84,7 +84,7 @@ class StorageManager
|
|||
/// @fixme Loading the addons & hooks here is really bad practice, but solves https://github.com/friendica/friendica/issues/11178
|
||||
/// clean solution = Making Addon & Hook dynamic and load them inside the constructor, so there's no custom load logic necessary anymore
|
||||
if ($includeAddon) {
|
||||
Addon::loadAddons();
|
||||
DI::addonHelper()->loadAddons();
|
||||
Hook::loadHooks();
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ namespace Friendica\Test;
|
|||
|
||||
use Friendica\Capabilities\ICanCreateResponses;
|
||||
use Friendica\Core\Addon;
|
||||
use Friendica\Core\Addon\AddonHelper;
|
||||
use Friendica\Core\Config\Capability\IManageConfigValues;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\DI;
|
||||
|
@ -201,7 +202,7 @@ abstract class ApiTestCase extends FixtureTestCase
|
|||
'plugin_admin' => function_exists($addon . '_addon_admin'),
|
||||
]);
|
||||
|
||||
Addon::loadAddons();
|
||||
$this->dice->create(AddonHelper::class)->loadAddons();
|
||||
Hook::loadHooks();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue