From 7661a78a43dbeb9ccba90a83bab4b68203a3c908 Mon Sep 17 00:00:00 2001 From: User123698745 Date: Thu, 3 Aug 2023 03:10:24 +0200 Subject: [PATCH] [core] add bridge not found warning message to frontpage (#3591) --- actions/FrontpageAction.php | 10 +++++++++- lib/BridgeFactory.php | 7 +++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/actions/FrontpageAction.php b/actions/FrontpageAction.php index 40d25ea4..64281b1e 100644 --- a/actions/FrontpageAction.php +++ b/actions/FrontpageAction.php @@ -4,12 +4,20 @@ final class FrontpageAction implements ActionInterface { public function execute(array $request) { + $messages = []; $showInactive = (bool) ($request['show_inactive'] ?? null); $activeBridges = 0; $bridgeFactory = new BridgeFactory(); $bridgeClassNames = $bridgeFactory->getBridgeClassNames(); + foreach ($bridgeFactory->getMissingEnabledBridges() as $missingEnabledBridge) { + $messages[] = [ + 'body' => sprintf('Warning : Bridge "%s" not found', $missingEnabledBridge), + 'level' => 'warning' + ]; + } + $formatFactory = new FormatFactory(); $formats = $formatFactory->getFormatNames(); @@ -24,7 +32,7 @@ final class FrontpageAction implements ActionInterface } return render(__DIR__ . '/../templates/frontpage.html.php', [ - 'messages' => [], + 'messages' => $messages, 'admin_email' => Configuration::getConfig('admin', 'email'), 'admin_telegram' => Configuration::getConfig('admin', 'telegram'), 'bridges' => $body, diff --git a/lib/BridgeFactory.php b/lib/BridgeFactory.php index 63633f4a..f302a27a 100644 --- a/lib/BridgeFactory.php +++ b/lib/BridgeFactory.php @@ -4,6 +4,7 @@ final class BridgeFactory { private $bridgeClassNames = []; private $enabledBridges = []; + private $missingEnabledBridges = []; public function __construct() { @@ -27,6 +28,7 @@ final class BridgeFactory if ($bridgeClassName) { $this->enabledBridges[] = $bridgeClassName; } else { + $this->missingEnabledBridges[] = $enabledBridge; Logger::info(sprintf('Bridge not found: %s', $enabledBridge)); } } @@ -69,4 +71,9 @@ final class BridgeFactory { return $this->bridgeClassNames; } + + public function getMissingEnabledBridges(): array + { + return $this->missingEnabledBridges; + } }