parent
b50a360ff1
commit
d41fbbf634
|
@ -180,7 +180,7 @@ class KickstartHelper
|
||||||
* @param IcingaObject[] $objects
|
* @param IcingaObject[] $objects
|
||||||
* @return IcingaObject[]
|
* @return IcingaObject[]
|
||||||
*/
|
*/
|
||||||
protected function sortByInheritance(array $objects)
|
protected function sortByParent(array $objects)
|
||||||
{
|
{
|
||||||
$sorted = array();
|
$sorted = array();
|
||||||
|
|
||||||
|
@ -190,17 +190,15 @@ class KickstartHelper
|
||||||
if ($cnt > 20) {
|
if ($cnt > 20) {
|
||||||
$this->throwObjectLoop($objects);
|
$this->throwObjectLoop($objects);
|
||||||
}
|
}
|
||||||
|
|
||||||
$unset = array();
|
$unset = array();
|
||||||
foreach ($objects as $key => $object) {
|
foreach ($objects as $key => $object) {
|
||||||
foreach ($object->imports()->listImportNames() as $parentName) {
|
$parentName = $object->get('parent');
|
||||||
if (! array_key_exists($parentName, $sorted)) {
|
if ($parentName === null || array_key_exists($parentName, $sorted)) {
|
||||||
continue 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$sorted[$object->getObjectName()] = $object;
|
$sorted[$object->getObjectName()] = $object;
|
||||||
$unset[] = $key;
|
$unset[] = $key;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($unset as $key) {
|
foreach ($unset as $key) {
|
||||||
unset($objects[$key]);
|
unset($objects[$key]);
|
||||||
|
@ -241,7 +239,7 @@ class KickstartHelper
|
||||||
protected function fetchZones()
|
protected function fetchZones()
|
||||||
{
|
{
|
||||||
$db = $this->db;
|
$db = $this->db;
|
||||||
$this->loadedZones = $this->sortByInheritance(
|
$this->loadedZones = $this->sortByParent(
|
||||||
$this->api()->setDb($db)->getZoneObjects()
|
$this->api()->setDb($db)->getZoneObjects()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -288,9 +286,7 @@ class KickstartHelper
|
||||||
protected function fetchEndpoints()
|
protected function fetchEndpoints()
|
||||||
{
|
{
|
||||||
$db = $this->db;
|
$db = $this->db;
|
||||||
$this->loadedEndpoints = $this->sortByInheritance(
|
$this->loadedEndpoints = $this->api()->setDb($db)->getEndpointObjects();
|
||||||
$this->api()->setDb($db)->getEndpointObjects()
|
|
||||||
);
|
|
||||||
|
|
||||||
$master = $this->getValue('endpoint');
|
$master = $this->getValue('endpoint');
|
||||||
if (array_key_exists($master, $this->loadedEndpoints)) {
|
if (array_key_exists($master, $this->loadedEndpoints)) {
|
||||||
|
@ -395,9 +391,10 @@ class KickstartHelper
|
||||||
$db = $this->db;
|
$db = $this->db;
|
||||||
$zdb = $db->getDbAdapter();
|
$zdb = $db->getDbAdapter();
|
||||||
$zdb->beginTransaction();
|
$zdb->beginTransaction();
|
||||||
|
/** @var IcingaObject $object */
|
||||||
foreach ($this->api()->setDb($db)->getCheckCommandObjects() as $object) {
|
foreach ($this->api()->setDb($db)->getCheckCommandObjects() as $object) {
|
||||||
if ($object::exists($object->object_name, $db)) {
|
if ($object::exists($object->object_name, $db)) {
|
||||||
$new = $object::load($object->object_name, $db)->replaceWith($object);
|
$new = $object::load($object->getObjectName(), $db)->replaceWith($object);
|
||||||
} else {
|
} else {
|
||||||
$new = $object;
|
$new = $object;
|
||||||
}
|
}
|
||||||
|
@ -407,7 +404,7 @@ class KickstartHelper
|
||||||
|
|
||||||
foreach ($this->api()->setDb($db)->getNotificationCommandObjects() as $object) {
|
foreach ($this->api()->setDb($db)->getNotificationCommandObjects() as $object) {
|
||||||
if ($object::exists($object->object_name, $db)) {
|
if ($object::exists($object->object_name, $db)) {
|
||||||
$new = $object::load($object->object_name, $db)->replaceWith($object);
|
$new = $object::load($object->getObjectName(), $db)->replaceWith($object);
|
||||||
} else {
|
} else {
|
||||||
$new = $object;
|
$new = $object;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue