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();
|
||||
if ($this->imports === null) {
|
||||
if ($this->hasBeenLoadedFromDb()) {
|
||||
// can not use hasBeenLoadedFromDb() when in onStore()
|
||||
if ($this->getProperty('id') !== null) {
|
||||
$this->imports = IcingaObjectImports::loadForStoredObject($this);
|
||||
} else {
|
||||
$this->imports = new IcingaObjectImports($this);
|
||||
|
|
|
@ -121,7 +121,9 @@ class TemplateTree
|
|||
|
||||
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'));
|
||||
} else {
|
||||
throw new RuntimeException(
|
||||
|
@ -223,8 +225,10 @@ class TemplateTree
|
|||
|
||||
public function getChildrenFor(IcingaObject $object)
|
||||
{
|
||||
if ($object->hasBeenLoadedFromDb()) {
|
||||
return $this->getChildrenById($object->getProperty('id'));
|
||||
// can not use hasBeenLoadedFromDb() when in onStore()
|
||||
$id = $object->getProperty('id');
|
||||
if ($id !== null) {
|
||||
return $this->getChildrenById($id);
|
||||
} else {
|
||||
throw new RuntimeException(
|
||||
'Loading children for unstored objects has not been implemented yet'
|
||||
|
@ -246,8 +250,10 @@ class TemplateTree
|
|||
|
||||
public function getDescendantsFor(IcingaObject $object)
|
||||
{
|
||||
if ($object->hasBeenLoadedFromDb()) {
|
||||
return $this->getDescendantsById($object->getProperty('id'));
|
||||
// can not use hasBeenLoadedFromDb() when in onStore()
|
||||
$id = $object->getProperty('id');
|
||||
if ($id !== null) {
|
||||
return $this->getDescendantsById($id);
|
||||
} else {
|
||||
throw new RuntimeException(
|
||||
'Loading descendants for unstored objects has not been implemented yet'
|
||||
|
|
Loading…
Reference in New Issue