mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-28 08:14:04 +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();
|
||||
}
|
||||
|
||||
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
|
||||
// is in place (currently for form element default values only)
|
||||
|
||||
if ($this->hasObject()) {
|
||||
$value = $this->getSentValue($name);
|
||||
if ($value === null) {
|
||||
if ($value === null || $value === '') {
|
||||
|
||||
$object = $this->getObject();
|
||||
|
||||
if ($object->hasProperty($name) && $object->$name !== null) {
|
||||
return $object->$name;
|
||||
if ($object->hasProperty($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;
|
||||
}
|
||||
|
||||
@ -732,7 +747,7 @@ abstract class DirectorObjectForm extends QuickForm
|
||||
return $val;
|
||||
}
|
||||
|
||||
if (null !== ($val = $this->getElement('object_type')->getValue())) {
|
||||
if (null !== ($val = $this->getElement($name)->getValue())) {
|
||||
return $val;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user