2014-09-01 15:00:20 +02:00
|
|
|
<?php
|
2015-02-04 10:46:36 +01:00
|
|
|
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
2014-09-01 15:00:20 +02:00
|
|
|
|
2014-11-14 11:17:22 +01:00
|
|
|
namespace Icinga\Module\Monitoring\Forms\Command;
|
2014-09-01 15:00:20 +02:00
|
|
|
|
2014-11-12 00:20:37 +01:00
|
|
|
use Icinga\Module\Monitoring\Backend\MonitoringBackend;
|
2014-09-01 15:00:20 +02:00
|
|
|
use Icinga\Module\Monitoring\Command\Transport\CommandTransport;
|
|
|
|
use Icinga\Web\Form;
|
|
|
|
use Icinga\Web\Request;
|
|
|
|
|
|
|
|
/**
|
2014-09-02 09:55:38 +02:00
|
|
|
* Base class for command forms
|
2014-09-01 15:00:20 +02:00
|
|
|
*/
|
2014-09-02 09:55:38 +02:00
|
|
|
abstract class CommandForm extends Form
|
2014-09-01 15:00:20 +02:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Monitoring backend
|
|
|
|
*
|
2015-07-28 12:20:03 +02:00
|
|
|
* @var MonitoringBackend
|
2014-09-01 15:00:20 +02:00
|
|
|
*/
|
|
|
|
protected $backend;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the monitoring backend
|
|
|
|
*
|
2014-11-12 00:20:37 +01:00
|
|
|
* @param MonitoringBackend $backend
|
2014-09-01 15:00:20 +02:00
|
|
|
*
|
|
|
|
* @return $this
|
|
|
|
*/
|
2014-11-12 00:20:37 +01:00
|
|
|
public function setBackend(MonitoringBackend $backend)
|
2014-09-01 15:00:20 +02:00
|
|
|
{
|
|
|
|
$this->backend = $backend;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the monitoring backend
|
|
|
|
*
|
2015-07-28 12:20:03 +02:00
|
|
|
* @return MonitoringBackend
|
2014-09-01 15:00:20 +02:00
|
|
|
*/
|
|
|
|
public function getBackend()
|
|
|
|
{
|
|
|
|
return $this->backend;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the transport used to send commands
|
|
|
|
*
|
|
|
|
* @param Request $request
|
|
|
|
*
|
2014-09-04 13:29:12 +02:00
|
|
|
* @return \Icinga\Module\Monitoring\Command\Transport\CommandTransportInterface
|
2014-09-01 15:00:20 +02:00
|
|
|
*/
|
|
|
|
public function getTransport(Request $request)
|
|
|
|
{
|
|
|
|
$instance = $request->getParam('instance');
|
|
|
|
if ($instance !== null) {
|
|
|
|
$transport = CommandTransport::create($instance);
|
|
|
|
} else {
|
|
|
|
$transport = CommandTransport::first();
|
|
|
|
}
|
|
|
|
return $transport;
|
|
|
|
}
|
|
|
|
}
|