mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-29 16:54:06 +02:00
DirectorObjectForm: getSentOrResolvedObjectValue
Introduce new helper method and fix former bahaviour
This commit is contained in:
parent
f9f1298bfd
commit
57463e9cf6
@ -702,22 +702,37 @@ abstract class DirectorObjectForm extends QuickForm
|
|||||||
return $this->getSentValue($name) === $this->getElement($name)->getLabel();
|
return $this->getSentValue($name) === $this->getElement($name)->getLabel();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSentOrObjectValue($name, $default = null)
|
public function getSentOrResolvedObjectValue($name, $default = null)
|
||||||
|
{
|
||||||
|
return $this->getSentOrObjectValue($name, $default, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getSentOrObjectValue($name, $default = null, $resolved = false)
|
||||||
{
|
{
|
||||||
// TODO: check whether getSentValue is still needed since element->getValue
|
// TODO: check whether getSentValue is still needed since element->getValue
|
||||||
// is in place (currently for form element default values only)
|
// is in place (currently for form element default values only)
|
||||||
|
|
||||||
if ($this->hasObject()) {
|
if ($this->hasObject()) {
|
||||||
$value = $this->getSentValue($name);
|
$value = $this->getSentValue($name);
|
||||||
if ($value === null) {
|
if ($value === null || $value === '') {
|
||||||
|
|
||||||
$object = $this->getObject();
|
$object = $this->getObject();
|
||||||
|
|
||||||
if ($object->hasProperty($name) && $object->$name !== null) {
|
if ($object->hasProperty($name)) {
|
||||||
return $object->$name;
|
if ($resolved) {
|
||||||
|
$objectProperty = $object->getResolvedProperty($name);
|
||||||
|
} else {
|
||||||
|
$objectProperty = $object->$name;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$objectProperty = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (null !== ($val = $this->getElement('object_type')->getValue())) {
|
if ($objectProperty !== null) {
|
||||||
|
return $objectProperty;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (null !== ($val = $this->getElement($name)->getValue())) {
|
||||||
return $val;
|
return $val;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -732,7 +747,7 @@ abstract class DirectorObjectForm extends QuickForm
|
|||||||
return $val;
|
return $val;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (null !== ($val = $this->getElement('object_type')->getValue())) {
|
if (null !== ($val = $this->getElement($name)->getValue())) {
|
||||||
return $val;
|
return $val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user