From 573e38ce339f09e17d3db79a72059384c618168c Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Wed, 16 Aug 2017 15:26:31 +0200 Subject: [PATCH] IcingaTimePeriodRangeTable: move and refactor --- .../tables/IcingaTimePeriodRangeTable.php | 61 ------------------- .../Web/Table/IcingaTimePeriodRangeTable.php | 61 +++++++++++++++++++ 2 files changed, 61 insertions(+), 61 deletions(-) delete mode 100644 application/tables/IcingaTimePeriodRangeTable.php create mode 100644 library/Director/Web/Table/IcingaTimePeriodRangeTable.php diff --git a/application/tables/IcingaTimePeriodRangeTable.php b/application/tables/IcingaTimePeriodRangeTable.php deleted file mode 100644 index 1778d45c..00000000 --- a/application/tables/IcingaTimePeriodRangeTable.php +++ /dev/null @@ -1,61 +0,0 @@ - 'r.timeperiod_id', - 'range_key' => 'r.range_key', - 'range_value' => 'r.range_value', - ); - } - - public function setTimePeriod(IcingaTimePeriod $period) - { - $this->period = $period; - $this->setConnection($period->getConnection()); - return $this; - } - - protected function getActionUrl($row) - { - return $this->url( - 'director/timeperiod/ranges', - array( - 'name' => $this->period->object_name, - 'range' => $row->range_key, - 'range_type' => 'include' - ) - ); - } - - public function getTitles() - { - $view = $this->view(); - return array( - 'range_key' => $view->translate('Day(s)'), - 'range_value' => $view->translate('Timeperiods'), - ); - } - - public function getBaseQuery() - { - return $this->db()->select()->from( - array('r' => 'icinga_timeperiod_range'), - array() - )->where('r.timeperiod_id = ?', $this->period->id); - } -} diff --git a/library/Director/Web/Table/IcingaTimePeriodRangeTable.php b/library/Director/Web/Table/IcingaTimePeriodRangeTable.php new file mode 100644 index 00000000..88c0fdfa --- /dev/null +++ b/library/Director/Web/Table/IcingaTimePeriodRangeTable.php @@ -0,0 +1,61 @@ +getConnection()); + $table->period = $period; + $table->attributes()->set('data-base-target', '_self'); + return $table; + } + + public function renderRow($row) + { + return $this::row([ + Link::create( + $row->range_key, + 'director/timeperiod/ranges', + array( + 'name' => $this->period->object_name, + 'range' => $row->range_key, + 'range_type' => 'include' + ) + ), + $row->range_value + ]); + } + + public function getColumnsToBeRendered() + { + return [ + $this->translate('Day(s)'), + $this->translate('Timeperiods'), + ]; + } + + public function prepareQuery() + { + return $this->db()->select()->from( + ['r' => 'icinga_timeperiod_range'], + [ + 'timeperiod_id' => 'r.timeperiod_id', + 'range_key' => 'r.range_key', + 'range_value' => 'r.range_value', + ] + )->where('r.timeperiod_id = ?', $this->period->id); + } +}