2017-07-20 22:29:00 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Icinga\Module\Director\Web\Table;
|
|
|
|
|
|
|
|
use Icinga\Module\Director\Objects\IcingaCommand;
|
|
|
|
use ipl\Html\Link;
|
|
|
|
use ipl\Web\Table\ZfQueryBasedTable;
|
|
|
|
|
|
|
|
class IcingaCommandArgumentTable extends ZfQueryBasedTable
|
|
|
|
{
|
|
|
|
/** @var IcingaCommand */
|
|
|
|
protected $command;
|
|
|
|
|
|
|
|
protected $searchColumns = array(
|
2017-07-21 08:23:52 +02:00
|
|
|
'ca.argument_name',
|
|
|
|
'ca.argument_value',
|
2017-07-20 22:29:00 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
public static function create(IcingaCommand $command)
|
|
|
|
{
|
|
|
|
$self = new static($command->getConnection());
|
|
|
|
$self->command = $command;
|
|
|
|
return $self;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function assemble()
|
|
|
|
{
|
|
|
|
$this->attributes()->set('data-base-target', '_self');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function renderRow($row)
|
|
|
|
{
|
|
|
|
return $this::row([
|
|
|
|
Link::create(
|
|
|
|
$row->argument_name,
|
|
|
|
'director/command/arguments',
|
|
|
|
[
|
|
|
|
'argument_id' => $row->id,
|
|
|
|
'name' => $this->command->getObjectName()
|
|
|
|
]
|
|
|
|
),
|
|
|
|
$row->argument_value
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getColumnsToBeRendered()
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
$this->translate('Argument'),
|
|
|
|
$this->translate('Value'),
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getColumns()
|
|
|
|
{
|
|
|
|
return array(
|
|
|
|
'id' => 'ca.id',
|
|
|
|
'argument_name' => "COALESCE(ca.argument_name, '(none)')",
|
|
|
|
'argument_value' => 'ca.argument_value',
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function prepareQuery()
|
|
|
|
{
|
|
|
|
return $this->db()->select()->from(
|
|
|
|
['ca' => 'icinga_command_argument'],
|
|
|
|
$this->getColumns()
|
|
|
|
)->where(
|
|
|
|
'ca.command_id = ?',
|
|
|
|
$this->command->get('id')
|
2017-07-21 08:23:52 +02:00
|
|
|
)->order('ca.sort_order')->order('ca.argument_name')->limit(100);
|
2017-07-20 22:29:00 +02:00
|
|
|
}
|
|
|
|
}
|