IcingaObject: Allow imports to be accessed during onStore()
This commit is contained in:
parent
039a6c8660
commit
ce9a8e1b09
|
@ -916,7 +916,8 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
|
||||||
{
|
{
|
||||||
$this->assertImportsSupport();
|
$this->assertImportsSupport();
|
||||||
if ($this->imports === null) {
|
if ($this->imports === null) {
|
||||||
if ($this->hasBeenLoadedFromDb()) {
|
// can not use hasBeenLoadedFromDb() when in onStore()
|
||||||
|
if ($this->getProperty('id') !== null) {
|
||||||
$this->imports = IcingaObjectImports::loadForStoredObject($this);
|
$this->imports = IcingaObjectImports::loadForStoredObject($this);
|
||||||
} else {
|
} else {
|
||||||
$this->imports = new IcingaObjectImports($this);
|
$this->imports = new IcingaObjectImports($this);
|
||||||
|
|
|
@ -121,7 +121,9 @@ class TemplateTree
|
||||||
|
|
||||||
public function getParentsFor(IcingaObject $object)
|
public function getParentsFor(IcingaObject $object)
|
||||||
{
|
{
|
||||||
if ($object->hasBeenLoadedFromDb()) {
|
// can not use hasBeenLoadedFromDb() when in onStore()
|
||||||
|
$id = $object->getProperty('id');
|
||||||
|
if ($id !== null) {
|
||||||
return $this->getParentsById($object->getProperty('id'));
|
return $this->getParentsById($object->getProperty('id'));
|
||||||
} else {
|
} else {
|
||||||
throw new RuntimeException(
|
throw new RuntimeException(
|
||||||
|
@ -223,8 +225,10 @@ class TemplateTree
|
||||||
|
|
||||||
public function getChildrenFor(IcingaObject $object)
|
public function getChildrenFor(IcingaObject $object)
|
||||||
{
|
{
|
||||||
if ($object->hasBeenLoadedFromDb()) {
|
// can not use hasBeenLoadedFromDb() when in onStore()
|
||||||
return $this->getChildrenById($object->getProperty('id'));
|
$id = $object->getProperty('id');
|
||||||
|
if ($id !== null) {
|
||||||
|
return $this->getChildrenById($id);
|
||||||
} else {
|
} else {
|
||||||
throw new RuntimeException(
|
throw new RuntimeException(
|
||||||
'Loading children for unstored objects has not been implemented yet'
|
'Loading children for unstored objects has not been implemented yet'
|
||||||
|
@ -246,8 +250,10 @@ class TemplateTree
|
||||||
|
|
||||||
public function getDescendantsFor(IcingaObject $object)
|
public function getDescendantsFor(IcingaObject $object)
|
||||||
{
|
{
|
||||||
if ($object->hasBeenLoadedFromDb()) {
|
// can not use hasBeenLoadedFromDb() when in onStore()
|
||||||
return $this->getDescendantsById($object->getProperty('id'));
|
$id = $object->getProperty('id');
|
||||||
|
if ($id !== null) {
|
||||||
|
return $this->getDescendantsById($id);
|
||||||
} else {
|
} else {
|
||||||
throw new RuntimeException(
|
throw new RuntimeException(
|
||||||
'Loading descendants for unstored objects has not been implemented yet'
|
'Loading descendants for unstored objects has not been implemented yet'
|
||||||
|
|
Loading…
Reference in New Issue