2015-06-30 11:19:31 +02:00
|
|
|
<?php
|
|
|
|
|
2015-10-20 22:34:04 +02:00
|
|
|
namespace Icinga\Module\Director\Controllers;
|
2015-06-30 11:19:31 +02:00
|
|
|
|
2017-07-20 22:29:00 +02:00
|
|
|
use Icinga\Module\Director\Forms\IcingaCommandArgumentForm;
|
|
|
|
use Icinga\Module\Director\Objects\IcingaCommand;
|
2015-10-20 22:34:04 +02:00
|
|
|
use Icinga\Module\Director\Web\Controller\ObjectController;
|
2017-07-20 22:29:00 +02:00
|
|
|
use Icinga\Module\Director\Web\Table\IcingaCommandArgumentTable;
|
2015-08-03 13:42:19 +02:00
|
|
|
|
2015-10-20 22:34:04 +02:00
|
|
|
class CommandController extends ObjectController
|
2015-06-30 11:19:31 +02:00
|
|
|
{
|
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;
|
2017-07-20 22:29:00 +02:00
|
|
|
/** @var IcingaCommand $o */
|
2017-07-04 21:22:20 +02:00
|
|
|
$o = $this->object;
|
|
|
|
$this->tabs()->activate('arguments');
|
2017-07-20 22:29:00 +02:00
|
|
|
$this->addTitle($this->translate('Command arguments: %s'), $o->getObjectName());
|
2017-07-04 21:22:20 +02:00
|
|
|
|
2017-07-20 22:29:00 +02:00
|
|
|
$form = IcingaCommandArgumentForm::load()->setCommandObject($o);
|
2017-07-04 21:22:20 +02:00
|
|
|
if ($id = $p->shift('argument_id')) {
|
2015-08-03 13:42:19 +02:00
|
|
|
$form->loadObject($id);
|
|
|
|
}
|
|
|
|
$form->handleRequest();
|
2017-07-21 08:23:52 +02:00
|
|
|
$this->content()->add([$form]);
|
|
|
|
IcingaCommandArgumentTable::create($o)->renderTo($this);
|
2015-08-03 13:42:19 +02:00
|
|
|
}
|
2015-06-30 11:19:31 +02:00
|
|
|
}
|