SyncruleController: clean up, explicitly use IDs
This commit is contained in:
parent
d13c6f2ecf
commit
1b1da71f31
|
@ -6,7 +6,6 @@ use Icinga\Module\Director\Forms\SyncCheckForm;
|
||||||
use Icinga\Module\Director\Forms\SyncPropertyForm;
|
use Icinga\Module\Director\Forms\SyncPropertyForm;
|
||||||
use Icinga\Module\Director\Forms\SyncRuleForm;
|
use Icinga\Module\Director\Forms\SyncRuleForm;
|
||||||
use Icinga\Module\Director\Forms\SyncRunForm;
|
use Icinga\Module\Director\Forms\SyncRunForm;
|
||||||
use Icinga\Module\Director\Objects\SyncProperty;
|
|
||||||
use Icinga\Module\Director\Web\Controller\ActionController;
|
use Icinga\Module\Director\Web\Controller\ActionController;
|
||||||
use Icinga\Module\Director\Objects\SyncRule;
|
use Icinga\Module\Director\Objects\SyncRule;
|
||||||
use Icinga\Module\Director\Objects\SyncRun;
|
use Icinga\Module\Director\Objects\SyncRun;
|
||||||
|
@ -21,9 +20,6 @@ use dipl\Html\Link;
|
||||||
class SyncruleController extends ActionController
|
class SyncruleController extends ActionController
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @throws \Icinga\Exception\ConfigurationError
|
|
||||||
* @throws \Icinga\Exception\Http\HttpNotFoundException
|
|
||||||
* @throws \Icinga\Exception\IcingaException
|
|
||||||
* @throws \Icinga\Exception\NotFoundError
|
* @throws \Icinga\Exception\NotFoundError
|
||||||
*/
|
*/
|
||||||
public function indexAction()
|
public function indexAction()
|
||||||
|
@ -106,7 +102,6 @@ class SyncruleController extends ActionController
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param SyncRule $rule
|
* @param SyncRule $rule
|
||||||
* @throws \Icinga\Exception\IcingaException
|
|
||||||
*/
|
*/
|
||||||
protected function addPropertyHint(SyncRule $rule)
|
protected function addPropertyHint(SyncRule $rule)
|
||||||
{
|
{
|
||||||
|
@ -122,7 +117,6 @@ class SyncruleController extends ActionController
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $msg
|
* @param $msg
|
||||||
* @throws \Icinga\Exception\IcingaException
|
|
||||||
*/
|
*/
|
||||||
protected function warning($msg)
|
protected function warning($msg)
|
||||||
{
|
{
|
||||||
|
@ -131,28 +125,17 @@ class SyncruleController extends ActionController
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $msg
|
* @param $msg
|
||||||
* @throws \Icinga\Exception\IcingaException
|
|
||||||
*/
|
*/
|
||||||
protected function error($msg)
|
protected function error($msg)
|
||||||
{
|
{
|
||||||
$this->content()->add(Html::tag('p', ['class' => 'error'], $msg));
|
$this->content()->add(Html::tag('p', ['class' => 'error'], $msg));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @throws \Icinga\Exception\ConfigurationError
|
|
||||||
* @throws \Icinga\Exception\Http\HttpNotFoundException
|
|
||||||
* @throws \Icinga\Exception\IcingaException
|
|
||||||
*/
|
|
||||||
public function addAction()
|
public function addAction()
|
||||||
{
|
{
|
||||||
$this->editAction();
|
$this->editAction();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @throws \Icinga\Exception\ConfigurationError
|
|
||||||
* @throws \Icinga\Exception\Http\HttpNotFoundException
|
|
||||||
* @throws \Icinga\Exception\IcingaException
|
|
||||||
*/
|
|
||||||
public function editAction()
|
public function editAction()
|
||||||
{
|
{
|
||||||
$form = SyncRuleForm::load()
|
$form = SyncRuleForm::load()
|
||||||
|
@ -160,7 +143,7 @@ class SyncruleController extends ActionController
|
||||||
->setDb($this->db());
|
->setDb($this->db());
|
||||||
|
|
||||||
if ($id = $this->params->get('id')) {
|
if ($id = $this->params->get('id')) {
|
||||||
$form->loadObject($id);
|
$form->loadObject((int) $id);
|
||||||
/** @var SyncRule $rule */
|
/** @var SyncRule $rule */
|
||||||
$rule = $form->getObject();
|
$rule = $form->getObject();
|
||||||
$this->tabs(new SyncRuleTabs($rule))->activate('edit');
|
$this->tabs(new SyncRuleTabs($rule))->activate('edit');
|
||||||
|
@ -190,11 +173,8 @@ class SyncruleController extends ActionController
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws \Icinga\Exception\ConfigurationError
|
|
||||||
* @throws \Icinga\Exception\Http\HttpNotFoundException
|
|
||||||
* @throws \Icinga\Exception\MissingParameterException
|
* @throws \Icinga\Exception\MissingParameterException
|
||||||
* @throws \Icinga\Exception\NotFoundError
|
* @throws \Icinga\Exception\NotFoundError
|
||||||
* @throws \Icinga\Exception\ProgrammingError
|
|
||||||
*/
|
*/
|
||||||
public function cloneAction()
|
public function cloneAction()
|
||||||
{
|
{
|
||||||
|
@ -225,8 +205,7 @@ class SyncruleController extends ActionController
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws \Icinga\Exception\Http\HttpNotFoundException
|
* @throws \Icinga\Exception\NotFoundError
|
||||||
* @throws \Icinga\Exception\IcingaException
|
|
||||||
*/
|
*/
|
||||||
public function propertyAction()
|
public function propertyAction()
|
||||||
{
|
{
|
||||||
|
@ -247,9 +226,7 @@ class SyncruleController extends ActionController
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws \Icinga\Exception\ConfigurationError
|
* @throws \Icinga\Exception\NotFoundError
|
||||||
* @throws \Icinga\Exception\Http\HttpNotFoundException
|
|
||||||
* @throws \Icinga\Exception\IcingaException
|
|
||||||
*/
|
*/
|
||||||
public function editpropertyAction()
|
public function editpropertyAction()
|
||||||
{
|
{
|
||||||
|
@ -257,9 +234,7 @@ class SyncruleController extends ActionController
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws \Icinga\Exception\ConfigurationError
|
* @throws \Icinga\Exception\NotFoundError
|
||||||
* @throws \Icinga\Exception\Http\HttpNotFoundException
|
|
||||||
* @throws \Icinga\Exception\IcingaException
|
|
||||||
*/
|
*/
|
||||||
public function addpropertyAction()
|
public function addpropertyAction()
|
||||||
{
|
{
|
||||||
|
@ -269,7 +244,7 @@ class SyncruleController extends ActionController
|
||||||
|
|
||||||
$form = SyncPropertyForm::load()->setDb($db);
|
$form = SyncPropertyForm::load()->setDb($db);
|
||||||
if ($id = $this->params->get('id')) {
|
if ($id = $this->params->get('id')) {
|
||||||
$form->loadObject($id);
|
$form->loadObject((int) $id);
|
||||||
$this->addTitle(
|
$this->addTitle(
|
||||||
$this->translate('Sync "%s": %s'),
|
$this->translate('Sync "%s": %s'),
|
||||||
$form->getObject()->get('destination_field'),
|
$form->getObject()->get('destination_field'),
|
||||||
|
@ -299,9 +274,6 @@ class SyncruleController extends ActionController
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws \Icinga\Exception\ConfigurationError
|
|
||||||
* @throws \Icinga\Exception\Http\HttpNotFoundException
|
|
||||||
* @throws \Icinga\Exception\IcingaException
|
|
||||||
* @throws \Icinga\Exception\NotFoundError
|
* @throws \Icinga\Exception\NotFoundError
|
||||||
*/
|
*/
|
||||||
public function historyAction()
|
public function historyAction()
|
||||||
|
@ -321,13 +293,11 @@ class SyncruleController extends ActionController
|
||||||
/**
|
/**
|
||||||
* @param string $key
|
* @param string $key
|
||||||
* @return SyncRule
|
* @return SyncRule
|
||||||
* @throws \Icinga\Exception\ConfigurationError
|
|
||||||
* @throws \Icinga\Exception\IcingaException
|
|
||||||
* @throws \Icinga\Exception\NotFoundError
|
* @throws \Icinga\Exception\NotFoundError
|
||||||
*/
|
*/
|
||||||
protected function requireSyncRule($key = 'id')
|
protected function requireSyncRule($key = 'id')
|
||||||
{
|
{
|
||||||
$id = $this->params->get($key);
|
$id = $this->params->get($key);
|
||||||
return SyncRule::load($id, $this->db());
|
return SyncRule::loadWithAutoIncId($id, $this->db());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue