From b91f9d3bcf417357fbd0836e6fb5eaa13e697f37 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Thu, 10 Oct 2019 13:38:55 +0200 Subject: [PATCH] ServiceController: Fetch service in method init() --- application/controllers/ServiceController.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/application/controllers/ServiceController.php b/application/controllers/ServiceController.php index eed1f297..55cab668 100644 --- a/application/controllers/ServiceController.php +++ b/application/controllers/ServiceController.php @@ -10,7 +10,10 @@ use Icinga\Module\Eagle\Widget\ServiceListItem; class ServiceController extends Controller { - public function indexAction() + /** @var Service The service object */ + protected $service; + + public function init() { $name = $this->params->shiftRequired('name'); $hostName = $this->params->shiftRequired('host_name'); @@ -34,6 +37,11 @@ class ServiceController extends Controller $volatileState->add($service); $volatileState->fetch(); - $this->addContent((new ServiceListItem($service))->setTag('div')); + $this->service = $service; + } + + public function indexAction() + { + $this->addContent((new ServiceListItem($this->service))->setTag('div')); } }