icingaweb2-module-director/application/controllers/CommandController.php

45 lines
1.3 KiB
PHP
Raw Normal View History

<?php
2015-10-20 22:34:04 +02:00
namespace Icinga\Module\Director\Controllers;
2015-10-20 22:34:04 +02:00
use Icinga\Module\Director\Web\Controller\ObjectController;
2015-08-03 13:42:19 +02:00
use Icinga\Data\Filter\Filter;
2015-10-20 22:34:04 +02:00
class CommandController extends ObjectController
{
2015-08-03 13:42:19 +02:00
public function init()
{
parent::init();
2017-07-04 21:22:20 +02:00
$o = $this->object;
if ($o && ! $o->isExternal()) {
$this->tabs()->add('arguments', [
2015-08-03 13:42:19 +02:00
'url' => 'director/command/arguments',
2017-07-04 21:22:20 +02:00
'urlParams' => ['name' => $o->getObjectName()],
2015-08-03 13:42:19 +02:00
'label' => 'Arguments'
2017-07-04 21:22:20 +02:00
]);
2015-08-03 13:42:19 +02:00
}
}
public function argumentsAction()
{
2017-07-04 21:22:20 +02:00
$p = $this->params;
$o = $this->object;
$this->tabs()->activate('arguments');
$this->setTitle($this->translate('Command arguments: %s'), $o->getObjectName());
/** @var \Icinga\Module\Director\Forms\IcingaCommandArgumentForm $form */
$form = $this->loadForm('icingaCommandArgument')->setCommandObject($o);
if ($id = $p->shift('argument_id')) {
2015-08-03 13:42:19 +02:00
$form->loadObject($id);
}
$form->handleRequest();
2017-07-04 21:22:20 +02:00
$filter = Filter::where('command', $p->get('name'));
$table = $this->loadTable('icingaCommandArgument')
->setCommandObject($o)
->setFilter($filter);
$this->content()->add([$form, $table]);
2015-08-03 13:42:19 +02:00
}
}