From fbd1adba39c8cce687010def2e66e54d040b70eb Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Tue, 23 Aug 2016 14:04:48 +0000 Subject: [PATCH] IcingaHostAppliedForServiceTable: new table --- .../IcingaHostAppliedForServiceTable.php | 95 +++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 application/tables/IcingaHostAppliedForServiceTable.php diff --git a/application/tables/IcingaHostAppliedForServiceTable.php b/application/tables/IcingaHostAppliedForServiceTable.php new file mode 100644 index 00000000..2b15bdf6 --- /dev/null +++ b/application/tables/IcingaHostAppliedForServiceTable.php @@ -0,0 +1,95 @@ +getValue() as $key => $var) { + $data[] = (object) array( + 'service' => $key, + ); + } + + $this->setConnection(new ArrayDatasource($data)); + return $this; + } + + public function count() + { + $query = clone($this->getBaseQuery()); + $this->applyFiltersToQuery($query); + return $query->count(); + } + + public function fetchData() + { + $query = $this->getBaseQuery()->columns($this->getColumns()); + + if ($this->hasLimit() || $this->hasOffset()) { + $query->limit($this->getLimit(), $this->getOffset()); + } + + $this->applyFiltersToQuery($query); + + return $query->fetchAll(); + } + + public function getColumns() + { + return array( + 'service' => 'service' + ); + } + + public function setTitle($title) + { + $this->title = $title; + return $this; + } + + public function setHost(IcingaHost $host) + { + $this->host = $host; + return $this; + } + + protected function getActionUrl($row) + { + $params = array( + 'name' => $this->host->object_name, + 'service' => $row->service, + ); + + return $this->url('director/host/appliedservice', $params); + } + + public function getTitles() + { + $view = $this->view(); + return array( + 'service' => $this->title ?: $view->translate('Servicename'), + ); + } + + public function getBaseQuery() + { + return $this->connection->select(); + } +}