From 9885d74d24e412f842edbe17783e9cb152fae7d8 Mon Sep 17 00:00:00 2001
From: Eric Lippmann <eric.lippmann@netways.de>
Date: Tue, 12 Jan 2016 08:58:32 +0100
Subject: [PATCH] monitoring: Fix ServiceController::getServiceActions() after
 changing hook usage

---
 .../application/controllers/HostController.php       |  6 +++---
 .../application/controllers/ServiceController.php    | 12 +++++-------
 .../views/scripts/show/components/actions.phtml      |  4 ++--
 3 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/modules/monitoring/application/controllers/HostController.php b/modules/monitoring/application/controllers/HostController.php
index 3bdb26097..1a695688f 100644
--- a/modules/monitoring/application/controllers/HostController.php
+++ b/modules/monitoring/application/controllers/HostController.php
@@ -3,8 +3,6 @@
 
 namespace Icinga\Module\Monitoring\Controllers;
 
-use Icinga\Web\Hook;
-use Icinga\Web\Navigation\Navigation;
 use Icinga\Module\Monitoring\Forms\Command\Object\AcknowledgeProblemCommandForm;
 use Icinga\Module\Monitoring\Forms\Command\Object\AddCommentCommandForm;
 use Icinga\Module\Monitoring\Forms\Command\Object\ProcessCheckResultCommandForm;
@@ -13,6 +11,8 @@ use Icinga\Module\Monitoring\Forms\Command\Object\ScheduleHostDowntimeCommandFor
 use Icinga\Module\Monitoring\Forms\Command\Object\SendCustomNotificationCommandForm;
 use Icinga\Module\Monitoring\Object\Host;
 use Icinga\Module\Monitoring\Web\Controller\MonitoredObjectController;
+use Icinga\Web\Hook;
+use Icinga\Web\Navigation\Navigation;
 
 class HostController extends MonitoredObjectController
 {
@@ -40,7 +40,7 @@ class HostController extends MonitoredObjectController
     /**
      * Get host actions from hook
      *
-     * @return array
+     * @return  Navigation
      */
     protected function getHostActions()
     {
diff --git a/modules/monitoring/application/controllers/ServiceController.php b/modules/monitoring/application/controllers/ServiceController.php
index 2c8f1f3f0..2358bfb7a 100644
--- a/modules/monitoring/application/controllers/ServiceController.php
+++ b/modules/monitoring/application/controllers/ServiceController.php
@@ -12,6 +12,7 @@ use Icinga\Module\Monitoring\Forms\Command\Object\SendCustomNotificationCommandF
 use Icinga\Module\Monitoring\Object\Service;
 use Icinga\Module\Monitoring\Web\Controller\MonitoredObjectController;
 use Icinga\Web\Hook;
+use Icinga\Web\Navigation\Navigation;
 
 class ServiceController extends MonitoredObjectController
 {
@@ -42,19 +43,16 @@ class ServiceController extends MonitoredObjectController
     /**
      * Get service actions from hook
      *
-     * @return array
+     * @return Navigation
      */
     protected function getServiceActions()
     {
-        $urls = array();
-
+        $navigation = new Navigation();
         foreach (Hook::all('Monitoring\\ServiceActions') as $hook) {
-            foreach ($hook->getActionsForService($this->object) as $id => $url) {
-                $urls[$id] = $url;
-            }
+            $navigation->merge($hook->getNavigation($this->object));
         }
 
-        return $urls;
+        return $navigation;
     }
 
     /**
diff --git a/modules/monitoring/application/views/scripts/show/components/actions.phtml b/modules/monitoring/application/views/scripts/show/components/actions.phtml
index 0e13da551..ad5b78cbc 100644
--- a/modules/monitoring/application/views/scripts/show/components/actions.phtml
+++ b/modules/monitoring/application/views/scripts/show/components/actions.phtml
@@ -32,7 +32,7 @@ if (isset($this->actions)) {
     $navigation->merge($this->actions);
 }
 
-if ($navigation->isEmpty() || !$navigation->hasRenderableItems()) {
+if ($navigation->isEmpty() || ! $navigation->hasRenderableItems()) {
     return;
 }
 
@@ -40,4 +40,4 @@ if ($navigation->isEmpty() || !$navigation->hasRenderableItems()) {
 <tr>
     <th><?= $this->translate('Actions'); ?></th>
     <?= $navigation->getRenderer()->setElementTag('td')->setCssClass('actions'); ?>
-</tr>
\ No newline at end of file
+</tr>