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

42 lines
1.3 KiB
PHP
Raw Normal View History

<?php
2015-10-20 22:34:04 +02:00
namespace Icinga\Module\Director\Controllers;
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;
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-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;
/** @var IcingaCommand $o */
2017-07-04 21:22:20 +02:00
$o = $this->object;
$this->tabs()->activate('arguments');
$this->addTitle($this->translate('Command arguments: %s'), $o->getObjectName());
2017-07-04 21:22:20 +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
}
}