mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-29 00:34:05 +02:00
BasketSnapshot: remove obsolete flag
This commit is contained in:
parent
25bca75e9b
commit
c3936f63bb
@ -220,16 +220,11 @@ class BasketSnapshot extends DbObject
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Db $connection
|
* @param Db $connection
|
||||||
* @param bool $replace
|
|
||||||
* @throws \Icinga\Exception\NotFoundError
|
* @throws \Icinga\Exception\NotFoundError
|
||||||
*/
|
*/
|
||||||
public function restoreTo(Db $connection, $replace = true)
|
public function restoreTo(Db $connection)
|
||||||
{
|
{
|
||||||
static::restoreJson(
|
static::restoreJson($this->getJsonDump(), $connection);
|
||||||
$this->getJsonDump(),
|
|
||||||
$connection,
|
|
||||||
$replace
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -250,14 +245,9 @@ class BasketSnapshot extends DbObject
|
|||||||
return $snapshot;
|
return $snapshot;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function restoreJson($string, Db $connection, $replace = true)
|
public static function restoreJson($string, Db $connection)
|
||||||
{
|
{
|
||||||
$snapshot = new static();
|
(new static())->restoreObjects(JsonString::decode($string), $connection);
|
||||||
$snapshot->restoreObjects(
|
|
||||||
JsonString::decode($string),
|
|
||||||
$connection,
|
|
||||||
$replace
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -266,16 +256,16 @@ class BasketSnapshot extends DbObject
|
|||||||
* @throws \Icinga\Exception\NotFoundError
|
* @throws \Icinga\Exception\NotFoundError
|
||||||
* @throws JsonDecodeException
|
* @throws JsonDecodeException
|
||||||
*/
|
*/
|
||||||
protected function restoreObjects(stdClass $all, Db $connection, $replace = true)
|
protected function restoreObjects(stdClass $all, Db $connection)
|
||||||
{
|
{
|
||||||
$db = $connection->getDbAdapter();
|
$db = $connection->getDbAdapter();
|
||||||
$db->beginTransaction();
|
$db->beginTransaction();
|
||||||
$fieldResolver = new BasketSnapshotFieldResolver($all, $connection);
|
$fieldResolver = new BasketSnapshotFieldResolver($all, $connection);
|
||||||
$this->restoreType($all, 'DataList', $fieldResolver, $connection, $replace);
|
$this->restoreType($all, 'DataList', $fieldResolver, $connection);
|
||||||
$this->restoreType($all, 'DatafieldCategory', $fieldResolver, $connection, $replace);
|
$this->restoreType($all, 'DatafieldCategory', $fieldResolver, $connection);
|
||||||
$fieldResolver->storeNewFields();
|
$fieldResolver->storeNewFields();
|
||||||
foreach ($this->restoreOrder as $typeName) {
|
foreach ($this->restoreOrder as $typeName) {
|
||||||
$this->restoreType($all, $typeName, $fieldResolver, $connection, $replace);
|
$this->restoreType($all, $typeName, $fieldResolver, $connection);
|
||||||
}
|
}
|
||||||
$db->commit();
|
$db->commit();
|
||||||
}
|
}
|
||||||
@ -290,13 +280,8 @@ class BasketSnapshot extends DbObject
|
|||||||
stdClass $all,
|
stdClass $all,
|
||||||
string $typeName,
|
string $typeName,
|
||||||
BasketSnapshotFieldResolver $fieldResolver,
|
BasketSnapshotFieldResolver $fieldResolver,
|
||||||
Db $connection,
|
Db $connection
|
||||||
bool $replace
|
|
||||||
) {
|
) {
|
||||||
if ($replace === false) {
|
|
||||||
throw new RuntimeException('Replace flag should no longer be in use');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($all->$typeName)) {
|
if (isset($all->$typeName)) {
|
||||||
$objects = (array) $all->$typeName;
|
$objects = (array) $all->$typeName;
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user