From 8484a27b5685f22ab209808c453893b04186c548 Mon Sep 17 00:00:00 2001 From: Alexander Fuhr Date: Thu, 30 Apr 2015 16:13:10 +0200 Subject: [PATCH] Add a backend problem menu item renderer to system menu refs #4139 --- .../BackendAvailabilityMenuItemRenderer.php | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 modules/monitoring/library/Monitoring/Web/Menu/BackendAvailabilityMenuItemRenderer.php diff --git a/modules/monitoring/library/Monitoring/Web/Menu/BackendAvailabilityMenuItemRenderer.php b/modules/monitoring/library/Monitoring/Web/Menu/BackendAvailabilityMenuItemRenderer.php new file mode 100644 index 000000000..186351a40 --- /dev/null +++ b/modules/monitoring/library/Monitoring/Web/Menu/BackendAvailabilityMenuItemRenderer.php @@ -0,0 +1,62 @@ +select()->from( + 'programstatus', + array( + 'is_currently_running' + ) + )->getQuery()->fetchRow()->is_currently_running; + } + + /** + * @see MenuItemRenderer::render() + */ + public function render(Menu $menu) + { + return $this->getBadge() . $this->createLink($menu); + } + + protected function getBadge() + { + if (! (bool)$this->isCurrentlyRunning()) { + return sprintf( + '
%s
', + mt('monitoring', 'monitoring backend is not running'), + 1 + ); + } + return ''; + } + + /** + * Get the problem data for the summary + * + * @return array|null + */ + public function getSummary() + { + if (! (bool)$this->isCurrentlyRunning()) { + return array( + 'problems' => 1, + 'title' => mt('monitoring', 'monitoring backend is not running') + ); + } + return null; + } +}