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