blob: 9d0760abc84fbba6af0c9724aca1dd6047374e32 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
<?php
/* Icinga Web 2 | (c) 2014 Icinga Development Team | GPLv2+ */
namespace Icinga\Module\Monitoring\Forms\Setup;
use Icinga\Web\Form;
use Icinga\Module\Monitoring\Forms\Config\TransportConfigForm;
class TransportPage extends Form
{
public function init()
{
$this->setName('setup_command_transport');
$this->setTitle($this->translate('Command Transport', 'setup.page.title'));
$this->addDescription($this->translate(
'Please define below how you want to send commands to your monitoring instance.'
));
$this->setValidatePartial(true);
}
public function createElements(array $formData)
{
$transportConfigForm = new TransportConfigForm();
$this->addSubForm($transportConfigForm, 'transport_form');
$transportConfigForm->create($formData);
$transportConfigForm->removeElement('instance');
$transportConfigForm->getElement('name')->setValue('icinga2');
}
public function getValues($suppressArrayNotation = false)
{
return $this->getSubForm('transport_form')->getValues($suppressArrayNotation);
}
/**
* 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;
}
}
|