2014-10-29 15:40:34 +01:00
|
|
|
<?php
|
2016-02-08 15:41:00 +01:00
|
|
|
/* Icinga Web 2 | (c) 2014 Icinga Development Team | GPLv2+ */
|
2014-10-29 15:40:34 +01:00
|
|
|
|
2014-11-14 11:17:22 +01:00
|
|
|
namespace Icinga\Module\Monitoring\Forms\Setup;
|
2014-10-29 15:40:34 +01:00
|
|
|
|
|
|
|
use Icinga\Web\Form;
|
2015-08-26 15:52:36 +02:00
|
|
|
use Icinga\Module\Monitoring\Forms\Config\TransportConfigForm;
|
2014-10-29 15:40:34 +01:00
|
|
|
|
2015-08-26 15:52:36 +02:00
|
|
|
class TransportPage extends Form
|
2014-10-29 15:40:34 +01:00
|
|
|
{
|
|
|
|
public function init()
|
|
|
|
{
|
2015-08-26 15:43:30 +02:00
|
|
|
$this->setName('setup_command_transport');
|
|
|
|
$this->setTitle($this->translate('Command Transport', 'setup.page.title'));
|
2015-03-02 18:36:04 +01:00
|
|
|
$this->addDescription($this->translate(
|
2015-08-26 15:43:30 +02:00
|
|
|
'Please define below how you want to send commands to your monitoring instance.'
|
2015-03-02 18:36:04 +01:00
|
|
|
));
|
2017-11-20 10:01:30 +01:00
|
|
|
$this->setValidatePartial(true);
|
2014-10-29 15:40:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function createElements(array $formData)
|
|
|
|
{
|
2015-08-26 15:52:36 +02:00
|
|
|
$transportConfigForm = new TransportConfigForm();
|
2015-08-26 15:43:30 +02:00
|
|
|
$this->addSubForm($transportConfigForm, 'transport_form');
|
|
|
|
$transportConfigForm->create($formData);
|
2015-08-27 16:33:10 +02:00
|
|
|
$transportConfigForm->removeElement('instance');
|
2015-08-26 15:43:30 +02:00
|
|
|
$transportConfigForm->getElement('name')->setValue('icinga2');
|
2015-07-03 15:07:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getValues($suppressArrayNotation = false)
|
|
|
|
{
|
2015-08-26 15:43:30 +02:00
|
|
|
return $this->getSubForm('transport_form')->getValues($suppressArrayNotation);
|
2014-10-29 15:40:34 +01:00
|
|
|
}
|
2017-11-20 10:01:30 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Run the configured backend's inspection checks and show the result, if necessary
|
|
|
|
*
|
|
|
|
* This will only run any validation if the user pushed the 'transport_validation' button.
|
|
|
|
*
|
|
|
|
* @param array $formData
|
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function isValidPartial(array $formData)
|
|
|
|
{
|
|
|
|
if (isset($formData['transport_validation']) && parent::isValid($formData)) {
|
|
|
|
$this->info($this->translate('The configuration has been successfully validated.'));
|
|
|
|
} elseif (! isset($formData['transport_validation'])) {
|
|
|
|
// This is usually done by isValid(Partial), but as we're not calling any of these...
|
|
|
|
$this->populate($formData);
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2014-10-29 15:40:34 +01:00
|
|
|
}
|