mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-31 01:34:12 +02:00
ImportsourceHookTable: move and refactor based...
...on SimpleQueryBasedTable
This commit is contained in:
parent
9f70f84423
commit
6f3d07f729
@ -1,14 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Icinga\Module\Director\Tables;
|
namespace Icinga\Module\Director\Web\Table;
|
||||||
|
|
||||||
use Icinga\Data\DataArray\ArrayDatasource;
|
use Icinga\Data\DataArray\ArrayDatasource;
|
||||||
use Icinga\Data\Paginatable;
|
|
||||||
use Icinga\Module\Director\Hook\ImportSourceHook;
|
use Icinga\Module\Director\Hook\ImportSourceHook;
|
||||||
use Icinga\Module\Director\Objects\ImportSource;
|
use Icinga\Module\Director\Objects\ImportSource;
|
||||||
use Icinga\Module\Director\Web\Table\QuickTable;
|
use ipl\Web\Table\SimpleQueryBasedTable;
|
||||||
|
|
||||||
class ImportsourceHookTable extends QuickTable
|
class ImportsourceHookTable extends SimpleQueryBasedTable
|
||||||
{
|
{
|
||||||
/** @var ImportSource */
|
/** @var ImportSource */
|
||||||
protected $source;
|
protected $source;
|
||||||
@ -46,47 +45,33 @@ class ImportsourceHookTable extends QuickTable
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTitles()
|
public function getColumnsToBeRendered()
|
||||||
{
|
{
|
||||||
$cols = $this->getColumns();
|
return $this->getColumns();
|
||||||
return array_combine($cols, $cols);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function count()
|
|
||||||
{
|
|
||||||
$q = clone($this->getBaseQuery());
|
|
||||||
return $q->count();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function sourceHook()
|
protected function sourceHook()
|
||||||
{
|
{
|
||||||
if ($this->sourceHook === null) {
|
if ($this->sourceHook === null) {
|
||||||
$this->sourceHook = ImportSourceHook::loadByName(
|
$this->sourceHook = ImportSourceHook::forImportSource(
|
||||||
$this->source->source_name,
|
$this->source
|
||||||
$this->connection()
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->sourceHook;
|
return $this->sourceHook;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function fetchData()
|
public function fetchQueryRows()
|
||||||
{
|
{
|
||||||
if ($this->dataCache === null) {
|
if ($this->dataCache === null) {
|
||||||
$query = $this->getBaseQuery()->columns($this->getColumns());
|
$this->dataCache = parent::fetchQueryRows();
|
||||||
|
|
||||||
if ($this->hasLimit() || $this->hasOffset()) {
|
|
||||||
$query->limit($this->getLimit(), $this->getOffset());
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->dataCache = $query->fetchAll();
|
|
||||||
$this->source->applyModifiers($this->dataCache);
|
$this->source->applyModifiers($this->dataCache);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->dataCache;
|
return $this->dataCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBaseQuery()
|
public function prepareQuery()
|
||||||
{
|
{
|
||||||
$ds = new ArrayDatasource($this->sourceHook()->fetchData());
|
$ds = new ArrayDatasource($this->sourceHook()->fetchData());
|
||||||
return $ds->select();
|
return $ds->select();
|
Loading…
x
Reference in New Issue
Block a user