mirror of
https://git.friendi.ca/friendica/friendica.git
synced 2025-06-08 00:14:32 +02:00
Replace Addon class with AddonHelper in stats modules
This commit is contained in:
parent
ffb621f0e4
commit
2e50e93872
2 changed files with 55 additions and 23 deletions
|
@ -8,8 +8,10 @@
|
||||||
namespace Friendica\Module;
|
namespace Friendica\Module;
|
||||||
|
|
||||||
use Friendica\App;
|
use Friendica\App;
|
||||||
|
use Friendica\App\Arguments;
|
||||||
|
use Friendica\App\BaseURL;
|
||||||
use Friendica\BaseModule;
|
use Friendica\BaseModule;
|
||||||
use Friendica\Core\Addon;
|
use Friendica\Core\Addon\AddonHelper;
|
||||||
use Friendica\Core\Config\Capability\IManageConfigValues;
|
use Friendica\Core\Config\Capability\IManageConfigValues;
|
||||||
use Friendica\Core\KeyValueStorage\Capability\IManageKeyValuePairs;
|
use Friendica\Core\KeyValueStorage\Capability\IManageKeyValuePairs;
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
|
@ -23,13 +25,27 @@ class Statistics extends BaseModule
|
||||||
protected $config;
|
protected $config;
|
||||||
/** @var IManageKeyValuePairs */
|
/** @var IManageKeyValuePairs */
|
||||||
protected $keyValue;
|
protected $keyValue;
|
||||||
|
private AddonHelper $addonHelper;
|
||||||
|
|
||||||
public function __construct(L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, IManageConfigValues $config, IManageKeyValuePairs $keyValue, Response $response, array $server, array $parameters = [])
|
public function __construct(
|
||||||
{
|
L10n $l10n,
|
||||||
|
BaseURL $baseUrl,
|
||||||
|
Arguments $args,
|
||||||
|
LoggerInterface $logger,
|
||||||
|
Profiler $profiler,
|
||||||
|
IManageConfigValues $config,
|
||||||
|
IManageKeyValuePairs $keyValue,
|
||||||
|
AddonHelper $addonHelper,
|
||||||
|
Response $response,
|
||||||
|
array $server,
|
||||||
|
array $parameters = []
|
||||||
|
) {
|
||||||
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
|
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
|
||||||
|
|
||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
$this->keyValue = $keyValue;
|
$this->keyValue = $keyValue;
|
||||||
|
$this->addonHelper = $addonHelper;
|
||||||
|
|
||||||
if (!$this->config->get("system", "nodeinfo")) {
|
if (!$this->config->get("system", "nodeinfo")) {
|
||||||
throw new NotFoundException();
|
throw new NotFoundException();
|
||||||
}
|
}
|
||||||
|
@ -43,16 +59,16 @@ class Statistics extends BaseModule
|
||||||
|
|
||||||
/// @todo mark the "service" addons and load them dynamically here
|
/// @todo mark the "service" addons and load them dynamically here
|
||||||
$services = [
|
$services = [
|
||||||
'appnet' => Addon::isEnabled('appnet'),
|
'appnet' => $this->addonHelper->isAddonEnabled('appnet'),
|
||||||
'bluesky' => Addon::isEnabled('bluesky'),
|
'bluesky' => $this->addonHelper->isAddonEnabled('bluesky'),
|
||||||
'dreamwidth' => Addon::isEnabled('dreamwidth'),
|
'dreamwidth' => $this->addonHelper->isAddonEnabled('dreamwidth'),
|
||||||
'gnusocial' => Addon::isEnabled('gnusocial'),
|
'gnusocial' => $this->addonHelper->isAddonEnabled('gnusocial'),
|
||||||
'libertree' => Addon::isEnabled('libertree'),
|
'libertree' => $this->addonHelper->isAddonEnabled('libertree'),
|
||||||
'livejournal' => Addon::isEnabled('livejournal'),
|
'livejournal' => $this->addonHelper->isAddonEnabled('livejournal'),
|
||||||
'pumpio' => Addon::isEnabled('pumpio'),
|
'pumpio' => $this->addonHelper->isAddonEnabled('pumpio'),
|
||||||
'twitter' => Addon::isEnabled('twitter'),
|
'twitter' => $this->addonHelper->isAddonEnabled('twitter'),
|
||||||
'tumblr' => Addon::isEnabled('tumblr'),
|
'tumblr' => $this->addonHelper->isAddonEnabled('tumblr'),
|
||||||
'wordpress' => Addon::isEnabled('wordpress'),
|
'wordpress' => $this->addonHelper->isAddonEnabled('wordpress'),
|
||||||
];
|
];
|
||||||
|
|
||||||
$statistics = array_merge([
|
$statistics = array_merge([
|
||||||
|
|
|
@ -8,8 +8,10 @@
|
||||||
namespace Friendica\Module;
|
namespace Friendica\Module;
|
||||||
|
|
||||||
use Friendica\App;
|
use Friendica\App;
|
||||||
|
use Friendica\App\Arguments;
|
||||||
|
use Friendica\App\BaseURL;
|
||||||
use Friendica\BaseModule;
|
use Friendica\BaseModule;
|
||||||
use Friendica\Core\Addon;
|
use Friendica\Core\Addon\AddonHelper;
|
||||||
use Friendica\Core\Config\Capability\IManageConfigValues;
|
use Friendica\Core\Config\Capability\IManageConfigValues;
|
||||||
use Friendica\Core\KeyValueStorage\Capability\IManageKeyValuePairs;
|
use Friendica\Core\KeyValueStorage\Capability\IManageKeyValuePairs;
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
|
@ -40,14 +42,28 @@ class Stats extends BaseModule
|
||||||
protected $logger;
|
protected $logger;
|
||||||
/** @var IManageKeyValuePairs */
|
/** @var IManageKeyValuePairs */
|
||||||
protected $keyValue;
|
protected $keyValue;
|
||||||
|
private AddonHelper $addonHelper;
|
||||||
|
|
||||||
public function __construct(L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, IManageConfigValues $config, IManageKeyValuePairs $keyValue, Database $dba, Response $response, array $server, array $parameters = [])
|
public function __construct(
|
||||||
{
|
L10n $l10n,
|
||||||
|
BaseURL $baseUrl,
|
||||||
|
Arguments $args,
|
||||||
|
LoggerInterface $logger,
|
||||||
|
Profiler $profiler,
|
||||||
|
IManageConfigValues $config,
|
||||||
|
IManageKeyValuePairs $keyValue,
|
||||||
|
Database $dba,
|
||||||
|
AddonHelper $addonHelper,
|
||||||
|
Response $response,
|
||||||
|
array $server,
|
||||||
|
array $parameters = []
|
||||||
|
) {
|
||||||
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
|
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
|
||||||
|
|
||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
$this->keyValue = $keyValue;
|
$this->keyValue = $keyValue;
|
||||||
$this->dba = $dba;
|
$this->dba = $dba;
|
||||||
|
$this->addonHelper = $addonHelper;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function content(array $request = []): string
|
protected function content(array $request = []): string
|
||||||
|
@ -164,11 +180,11 @@ class Stats extends BaseModule
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
if (Addon::isEnabled('bluesky')) {
|
if ($this->addonHelper->isAddonEnabled('bluesky')) {
|
||||||
$statistics['packets']['inbound'][Protocol::BLUESKY] = intval($this->keyValue->get('stats_packets_inbound_' . Protocol::BLUESKY) ?? 0);
|
$statistics['packets']['inbound'][Protocol::BLUESKY] = intval($this->keyValue->get('stats_packets_inbound_' . Protocol::BLUESKY) ?? 0);
|
||||||
$statistics['packets']['outbound'][Protocol::BLUESKY] = intval($this->keyValue->get('stats_packets_outbound_' . Protocol::BLUESKY) ?? 0);
|
$statistics['packets']['outbound'][Protocol::BLUESKY] = intval($this->keyValue->get('stats_packets_outbound_' . Protocol::BLUESKY) ?? 0);
|
||||||
}
|
}
|
||||||
if (Addon::isEnabled('tumblr')) {
|
if ($this->addonHelper->isAddonEnabled('tumblr')) {
|
||||||
$statistics['packets']['inbound'][Protocol::TUMBLR] = intval($this->keyValue->get('stats_packets_inbound_' . Protocol::TUMBLR) ?? 0);
|
$statistics['packets']['inbound'][Protocol::TUMBLR] = intval($this->keyValue->get('stats_packets_inbound_' . Protocol::TUMBLR) ?? 0);
|
||||||
$statistics['packets']['outbound'][Protocol::TUMBLR] = intval($this->keyValue->get('stats_packets_outbound_' . Protocol::TUMBLR) ?? 0);
|
$statistics['packets']['outbound'][Protocol::TUMBLR] = intval($this->keyValue->get('stats_packets_outbound_' . Protocol::TUMBLR) ?? 0);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue