mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-26 07:14:35 +02:00
CommandForm: Use the CommandTransport class directly
Provides a fallback mechanism now and will check the instance's name soon. refs #8981 refs #9651
This commit is contained in:
parent
fcbd24e28e
commit
e04c19a819
@ -3,10 +3,12 @@
|
|||||||
|
|
||||||
namespace Icinga\Module\Monitoring\Forms\Command;
|
namespace Icinga\Module\Monitoring\Forms\Command;
|
||||||
|
|
||||||
use Icinga\Module\Monitoring\Backend\MonitoringBackend;
|
use Icinga\Exception\ConfigurationError;
|
||||||
use Icinga\Module\Monitoring\Command\Transport\CommandTransport;
|
|
||||||
use Icinga\Web\Form;
|
use Icinga\Web\Form;
|
||||||
use Icinga\Web\Request;
|
use Icinga\Web\Request;
|
||||||
|
use Icinga\Module\Monitoring\Backend\MonitoringBackend;
|
||||||
|
use Icinga\Module\Monitoring\Command\Transport\CommandTransport;
|
||||||
|
use Icinga\Module\Monitoring\Command\Transport\CommandTransportInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for command forms
|
* Base class for command forms
|
||||||
@ -46,18 +48,28 @@ abstract class CommandForm extends Form
|
|||||||
/**
|
/**
|
||||||
* Get the transport used to send commands
|
* Get the transport used to send commands
|
||||||
*
|
*
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
*
|
*
|
||||||
* @return \Icinga\Module\Monitoring\Command\Transport\CommandTransportInterface
|
* @return CommandTransportInterface
|
||||||
|
*
|
||||||
|
* @throws ConfigurationError
|
||||||
*/
|
*/
|
||||||
public function getTransport(Request $request)
|
public function getTransport(Request $request)
|
||||||
{
|
{
|
||||||
$transportName = $request->getParam('transport');
|
if (($transportName = $request->getParam('transport')) !== null) {
|
||||||
if ($transportName !== null) {
|
$config = CommandTransport::getConfig();
|
||||||
$transport = CommandTransport::create($transportName);
|
if ($config->hasSection($transportName)) {
|
||||||
|
$transport = CommandTransport::createTransport($config->getSection($transportName));
|
||||||
|
} else {
|
||||||
|
throw new ConfigurationError(sprintf(
|
||||||
|
mt('monitoring', 'Command transport "%s" not found.'),
|
||||||
|
$transportName
|
||||||
|
));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$transport = CommandTransport::first();
|
$transport = new CommandTransport();
|
||||||
}
|
}
|
||||||
|
|
||||||
return $transport;
|
return $transport;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user