Provide API transport in the transport config form

refs #11398
This commit is contained in:
Eric Lippmann 2016-09-01 10:48:36 +02:00
parent 9b310ca1ca
commit 3ccbf37161

View File

@ -7,8 +7,10 @@ use InvalidArgumentException;
use Icinga\Exception\IcingaException; use Icinga\Exception\IcingaException;
use Icinga\Exception\NotFoundError; use Icinga\Exception\NotFoundError;
use Icinga\Forms\ConfigForm; use Icinga\Forms\ConfigForm;
use Icinga\Module\Monitoring\Command\Transport\ApiCommandTransport;
use Icinga\Module\Monitoring\Command\Transport\LocalCommandFile; use Icinga\Module\Monitoring\Command\Transport\LocalCommandFile;
use Icinga\Module\Monitoring\Command\Transport\RemoteCommandFile; use Icinga\Module\Monitoring\Command\Transport\RemoteCommandFile;
use Icinga\Module\Monitoring\Forms\Config\Transport\ApiTransportForm;
use Icinga\Module\Monitoring\Forms\Config\Transport\LocalTransportForm; use Icinga\Module\Monitoring\Forms\Config\Transport\LocalTransportForm;
use Icinga\Module\Monitoring\Forms\Config\Transport\RemoteTransportForm; use Icinga\Module\Monitoring\Forms\Config\Transport\RemoteTransportForm;
@ -68,7 +70,7 @@ class TransportConfigForm extends ConfigForm
* *
* @param string $type The transport type for which to return a form * @param string $type The transport type for which to return a form
* *
* @return Form * @return \Icinga\Web\Form
* *
* @throws InvalidArgumentException In case the given transport type is invalid * @throws InvalidArgumentException In case the given transport type is invalid
*/ */
@ -79,6 +81,8 @@ class TransportConfigForm extends ConfigForm
return new LocalTransportForm(); return new LocalTransportForm();
case RemoteCommandFile::TRANSPORT; case RemoteCommandFile::TRANSPORT;
return new RemoteTransportForm(); return new RemoteTransportForm();
case ApiCommandTransport::TRANSPORT:
return new ApiTransportForm();
default: default:
throw new InvalidArgumentException( throw new InvalidArgumentException(
sprintf($this->translate('Invalid command transport type "%s" given'), $type) sprintf($this->translate('Invalid command transport type "%s" given'), $type)
@ -223,7 +227,8 @@ class TransportConfigForm extends ConfigForm
$transportTypes = array( $transportTypes = array(
LocalCommandFile::TRANSPORT => $this->translate('Local Command File'), LocalCommandFile::TRANSPORT => $this->translate('Local Command File'),
RemoteCommandFile::TRANSPORT => $this->translate('Remote Command File') RemoteCommandFile::TRANSPORT => $this->translate('Remote Command File'),
ApiCommandTransport::TRANSPORT => $this->translate('Icinga 2 API')
); );
$transportType = isset($formData['transport']) ? $formData['transport'] : null; $transportType = isset($formData['transport']) ? $formData['transport'] : null;