mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-30 17:24:18 +02:00
IcingaObject: implement supportsAssignRules
This commit is contained in:
parent
b6d97171e1
commit
217fb38517
@ -25,7 +25,7 @@ class AssignListSubForm extends QuickSubForm
|
||||
{
|
||||
$idx = -1;
|
||||
|
||||
if ($this->object && $this->object->isApplyRule()) {
|
||||
if ($this->object && $this->object->supportsAssignments()) {
|
||||
// $this->setElementValue('assignlist', $object->assignments()->getFormValues());
|
||||
foreach ($this->object->assignments()->getFormValues() as $values) {
|
||||
$idx++;
|
||||
|
@ -17,8 +17,8 @@ class IcingaHostGroupForm extends DirectorObjectForm
|
||||
));
|
||||
|
||||
$this->addGroupDisplayNameElement()
|
||||
->addAssignmentElements()
|
||||
->setButtons();
|
||||
$this->addAssignmentElements();
|
||||
}
|
||||
|
||||
public function addAssignmentElements()
|
||||
|
@ -6,6 +6,8 @@ class IcingaHostGroup extends IcingaObjectGroup
|
||||
{
|
||||
protected $table = 'icinga_hostgroup';
|
||||
|
||||
// TODO: move to IcingaObjectGroup when supported for ServiceGroup
|
||||
protected $supportsApplyRules = true;
|
||||
public function supportsAssignments()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -257,11 +257,26 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
|
||||
return $this->supportsFields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether this object can be rendered as 'apply Object'
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function supportsApplyRules()
|
||||
{
|
||||
return $this->supportsApplyRules;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether this object supports 'assign' properties
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function supportsAssignments()
|
||||
{
|
||||
return $this->isApplyRule();
|
||||
}
|
||||
|
||||
public function resolveUnresolvedRelatedProperties()
|
||||
{
|
||||
foreach ($this->unresolvedRelatedProperties as $name => $p) {
|
||||
@ -309,7 +324,7 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($this->isApplyRule() && $this->assignments !== null && $this->assignments()->hasBeenModified()) {
|
||||
if ($this->supportsAssignments() && $this->assignments !== null && $this->assignments()->hasBeenModified()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1081,7 +1096,7 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
|
||||
|
||||
protected function storeAssignments()
|
||||
{
|
||||
if ($this->isApplyRule()) {
|
||||
if ($this->supportsAssignments()) {
|
||||
$this->assignments !== null && $this->assignments()->store();
|
||||
}
|
||||
|
||||
@ -1576,7 +1591,7 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
|
||||
|
||||
protected function renderAssignments()
|
||||
{
|
||||
if ($this->isApplyRule()) {
|
||||
if ($this->supportsAssignments()) {
|
||||
return $this->assignments()->toConfigString();
|
||||
} else {
|
||||
return '';
|
||||
@ -1908,7 +1923,7 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
|
||||
);
|
||||
}
|
||||
|
||||
if ($this->isApplyRule()) {
|
||||
if ($this->supportsAssignments()) {
|
||||
$props['assignments'] = $this->assignments()->getPlain();
|
||||
}
|
||||
|
||||
@ -2087,7 +2102,7 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->isApplyRule()) {
|
||||
if ($this->supportsAssignments()) {
|
||||
$props['assignments'] = $this->assignments()->getUnmodifiedPlain();
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ class IcingaObjectAssignments
|
||||
|
||||
public function __construct(IcingaObject $object)
|
||||
{
|
||||
if (! $object->isApplyRule()) {
|
||||
if (! $object->supportsAssignments()) {
|
||||
throw new ProgrammingError(
|
||||
'I can only assign for applied objects, got %s',
|
||||
$object->object_type
|
||||
|
@ -832,7 +832,7 @@ abstract class DirectorObjectForm extends QuickForm
|
||||
}
|
||||
|
||||
if ($object instanceof IcingaObject) {
|
||||
if ($object->isApplyRule()) {
|
||||
if ($object->supportsAssignments()) {
|
||||
$this->setElementValue('assignlist', $object->assignments()->getFormValues());
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user