mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-31 01:34:12 +02:00
parent
164d1f5874
commit
cb355f9b90
@ -57,18 +57,17 @@ class Exporter
|
|||||||
/** @var FieldReferenceLoader */
|
/** @var FieldReferenceLoader */
|
||||||
protected $fieldReferenceLoader;
|
protected $fieldReferenceLoader;
|
||||||
|
|
||||||
/** @var bool */
|
|
||||||
protected $exportHostServices = false;
|
protected $exportHostServices = false;
|
||||||
|
|
||||||
protected $showDefaults = false;
|
protected $showDefaults = false;
|
||||||
|
protected $showIds = false;
|
||||||
protected $resolveObjects = false;
|
protected $resolveObjects = false;
|
||||||
|
|
||||||
/**
|
/** @var Db */
|
||||||
* @var Db
|
|
||||||
*/
|
|
||||||
protected $connection;
|
protected $connection;
|
||||||
|
|
||||||
|
/** @var ?array */
|
||||||
|
protected $chosenProperties = null;
|
||||||
|
|
||||||
public function __construct(Db $connection)
|
public function __construct(Db $connection)
|
||||||
{
|
{
|
||||||
$this->connection = $connection;
|
$this->connection = $connection;
|
||||||
@ -85,6 +84,17 @@ class Exporter
|
|||||||
$this->stripDeniedProperties($props, $object);
|
$this->stripDeniedProperties($props, $object);
|
||||||
$this->appendTypeSpecificRelations($props, $object);
|
$this->appendTypeSpecificRelations($props, $object);
|
||||||
|
|
||||||
|
if ($this->chosenProperties !== null) {
|
||||||
|
$chosen = [];
|
||||||
|
foreach ($this->chosenProperties as $k) {
|
||||||
|
if (array_key_exists($k, $props)) {
|
||||||
|
$chosen[$k] = $props[$k];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$props = $chosen;
|
||||||
|
}
|
||||||
|
|
||||||
ksort($props);
|
ksort($props);
|
||||||
return (object) $props;
|
return (object) $props;
|
||||||
}
|
}
|
||||||
@ -101,12 +111,24 @@ class Exporter
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function showIds($show = true)
|
||||||
|
{
|
||||||
|
$this->showIds = $show;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function resolveObjects($resolve = true)
|
public function resolveObjects($resolve = true)
|
||||||
{
|
{
|
||||||
$this->resolveObjects = $resolve;
|
$this->resolveObjects = $resolve;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function filterProperties(array $properties)
|
||||||
|
{
|
||||||
|
$this->chosenProperties = $properties;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
protected function appendTypeSpecificRelations(array &$props, DbObject $object)
|
protected function appendTypeSpecificRelations(array &$props, DbObject $object)
|
||||||
{
|
{
|
||||||
if ($object instanceof DirectorDatalist) {
|
if ($object instanceof DirectorDatalist) {
|
||||||
@ -214,7 +236,9 @@ class Exporter
|
|||||||
{
|
{
|
||||||
// TODO: this used to exist. Double-check all imports to verify it's not in use
|
// TODO: this used to exist. Double-check all imports to verify it's not in use
|
||||||
// $originalId = $props['id'];
|
// $originalId = $props['id'];
|
||||||
|
if (! $this->showIds) {
|
||||||
unset($props['id']);
|
unset($props['id']);
|
||||||
|
}
|
||||||
$class = get_class($object);
|
$class = get_class($object);
|
||||||
if (isset(self::$denyProperties[$class])) {
|
if (isset(self::$denyProperties[$class])) {
|
||||||
foreach (self::$denyProperties[$class] as $key) {
|
foreach (self::$denyProperties[$class] as $key) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user