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