mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-30 01:04:12 +02:00
DirectorObjectForm: refactor getSentOrObjectValue
This commit is contained in:
parent
5e540880e5
commit
747fd966d2
@ -25,6 +25,8 @@ abstract class DirectorObjectForm extends QuickForm
|
|||||||
|
|
||||||
protected $displayGroups = array();
|
protected $displayGroups = array();
|
||||||
|
|
||||||
|
protected $resolvedImports = false;
|
||||||
|
|
||||||
protected function object($values = array())
|
protected function object($values = array())
|
||||||
{
|
{
|
||||||
if ($this->object === null) {
|
if ($this->object === null) {
|
||||||
@ -45,6 +47,33 @@ abstract class DirectorObjectForm extends QuickForm
|
|||||||
return $this->object;
|
return $this->object;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function assertResolvedImports()
|
||||||
|
{
|
||||||
|
if ($this->resolvedImports) {
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->resolvedImports = true;
|
||||||
|
$object = $this->object;
|
||||||
|
|
||||||
|
if (! $object instanceof IcingaObject) {
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
if (! $object->supportsImports()) {
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
if ($this->hasBeenSent()) {
|
||||||
|
if ($el = $this->getElement('imports')) {
|
||||||
|
$this->populate($this->getRequest()->getPost());
|
||||||
|
$object->imports = $el->getValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->object->importedObjects();
|
||||||
|
$object->resolveUnresolvedRelatedProperties();
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
protected function isObject()
|
protected function isObject()
|
||||||
{
|
{
|
||||||
return $this->getSentOrObjectValue('object_type') === 'object';
|
return $this->getSentOrObjectValue('object_type') === 'object';
|
||||||
@ -825,53 +854,50 @@ abstract class DirectorObjectForm extends QuickForm
|
|||||||
// 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);
|
if ($this->hasBeenSent()) {
|
||||||
if ($value === null || $value === '') {
|
|
||||||
|
|
||||||
$object = $this->getObject();
|
return $this->getSentValue($name, $default);
|
||||||
|
} else {
|
||||||
|
if (strlen($val = $this->getValue($name))) {
|
||||||
|
|
||||||
if ($object->hasProperty($name)) {
|
|
||||||
if ($resolved && $object->supportsImports()) {
|
|
||||||
$objectProperty = $object->getResolvedProperty($name);
|
|
||||||
/*
|
|
||||||
var_dump($name);
|
|
||||||
var_dump($objectProperty);
|
|
||||||
print_r($object);
|
|
||||||
|
|
||||||
*/
|
|
||||||
} else {
|
|
||||||
$objectProperty = $object->$name;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$objectProperty = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($objectProperty !== null) {
|
|
||||||
return $objectProperty;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (null !== ($val = $this->getElement($name)->getValue())) {
|
|
||||||
return $val;
|
return $val;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $default;
|
return $default;
|
||||||
} else {
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Has Object:
|
||||||
|
|
||||||
|
if (!$resolved && $this->hasBeenSent()) {
|
||||||
|
if (strlen($value = $this->getSentValue($name))) {
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
|
||||||
if (null !== ($val = $this->getSentValue($name))) {
|
|
||||||
return $val;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (null !== ($val = $this->getElement($name)->getValue())) {
|
|
||||||
return $val;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $default;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$object = $this->getObject();
|
||||||
|
|
||||||
|
if ($object->hasProperty($name)) {
|
||||||
|
if ($resolved && $object->supportsImports()) {
|
||||||
|
$this->assertResolvedImports();
|
||||||
|
$objectProperty = $object->getResolvedProperty($name);
|
||||||
|
} else {
|
||||||
|
$objectProperty = $object->$name;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$objectProperty = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($objectProperty !== null) {
|
||||||
|
return $objectProperty;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strlen($val = $this->getElement($name)->getValue())) {
|
||||||
|
return $val;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $default;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function loadObject($id)
|
public function loadObject($id)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user