parent
8a3d55b059
commit
f576e349a6
|
@ -43,6 +43,7 @@ next (will be 1.8.0)
|
||||||
* FEATURE: Property Modifier: negate boolean (#2227)
|
* FEATURE: Property Modifier: negate boolean (#2227)
|
||||||
* FEATURE: Property Modifier Reject/Select: improve usability (#2228)
|
* FEATURE: Property Modifier Reject/Select: improve usability (#2228)
|
||||||
* FEATURE: Property Modifier: clone rows for every entry of an Array (#2192)
|
* FEATURE: Property Modifier: clone rows for every entry of an Array (#2192)
|
||||||
|
* FEATURE: Property Modifier: unique array values (#2229)
|
||||||
* FEATURE: Import Sources now allows downloading previewed data as JSON (#2096)
|
* FEATURE: Import Sources now allows downloading previewed data as JSON (#2096)
|
||||||
* FEATURE: REST API Import now allows custom headers (#2132)
|
* FEATURE: REST API Import now allows custom headers (#2132)
|
||||||
* FEATURE: REST API Import can now extract nested properties (#2132)
|
* FEATURE: REST API Import can now extract nested properties (#2132)
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Icinga\Module\Director\PropertyModifier;
|
||||||
|
|
||||||
|
use Icinga\Exception\InvalidPropertyException;
|
||||||
|
use Icinga\Module\Director\Hook\PropertyModifierHook;
|
||||||
|
use function array_unique;
|
||||||
|
use function array_values;
|
||||||
|
use function is_array;
|
||||||
|
|
||||||
|
class PropertyModifierArrayUnique extends PropertyModifierHook
|
||||||
|
{
|
||||||
|
public function getName()
|
||||||
|
{
|
||||||
|
return 'Unique Array Values';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function hasArraySupport()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function transform($value)
|
||||||
|
{
|
||||||
|
if (empty($value)) {
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! is_array($value)) {
|
||||||
|
throw new InvalidPropertyException(
|
||||||
|
'The ArrayUnique property modifier can be applied to arrays only'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return array_values(array_unique($value));
|
||||||
|
}
|
||||||
|
}
|
|
@ -20,6 +20,7 @@ use Icinga\Module\Director\Job\SyncJob;
|
||||||
use Icinga\Module\Director\PropertyModifier\PropertyModifierArrayElementByPosition;
|
use Icinga\Module\Director\PropertyModifier\PropertyModifierArrayElementByPosition;
|
||||||
use Icinga\Module\Director\PropertyModifier\PropertyModifierArrayFilter;
|
use Icinga\Module\Director\PropertyModifier\PropertyModifierArrayFilter;
|
||||||
use Icinga\Module\Director\PropertyModifier\PropertyModifierArrayToRow;
|
use Icinga\Module\Director\PropertyModifier\PropertyModifierArrayToRow;
|
||||||
|
use Icinga\Module\Director\PropertyModifier\PropertyModifierArrayUnique;
|
||||||
use Icinga\Module\Director\PropertyModifier\PropertyModifierBitmask;
|
use Icinga\Module\Director\PropertyModifier\PropertyModifierBitmask;
|
||||||
use Icinga\Module\Director\PropertyModifier\PropertyModifierCombine;
|
use Icinga\Module\Director\PropertyModifier\PropertyModifierCombine;
|
||||||
use Icinga\Module\Director\PropertyModifier\PropertyModifierDnsRecords;
|
use Icinga\Module\Director\PropertyModifier\PropertyModifierDnsRecords;
|
||||||
|
@ -87,6 +88,7 @@ $directorHooks = [
|
||||||
PropertyModifierArrayElementByPosition::class,
|
PropertyModifierArrayElementByPosition::class,
|
||||||
PropertyModifierArrayFilter::class,
|
PropertyModifierArrayFilter::class,
|
||||||
PropertyModifierArrayToRow::class,
|
PropertyModifierArrayToRow::class,
|
||||||
|
PropertyModifierArrayUnique::class,
|
||||||
PropertyModifierBitmask::class,
|
PropertyModifierBitmask::class,
|
||||||
PropertyModifierCombine::class,
|
PropertyModifierCombine::class,
|
||||||
PropertyModifierDnsRecords::class,
|
PropertyModifierDnsRecords::class,
|
||||||
|
|
Loading…
Reference in New Issue