mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-29 08:44:11 +02:00
PropertyModifierBitmask: new bitmask modifier
This commit is contained in:
parent
dee5c422f2
commit
e3852fecce
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace Icinga\Module\Director\PropertyModifier;
|
||||
|
||||
use Icinga\Exception\InvalidPropertyException;
|
||||
use Icinga\Module\Director\Hook\PropertyModifierHook;
|
||||
use Icinga\Module\Director\Web\Form\QuickForm;
|
||||
|
||||
class PropertyModifierBitmask extends PropertyModifierHook
|
||||
{
|
||||
public static function addSettingsFormFields(QuickForm $form)
|
||||
{
|
||||
$form->addElement('text', 'bitmask', array(
|
||||
'label' => 'Bitmask',
|
||||
'description' => $form->translate(
|
||||
'The numeric bitmask you want to apply. In case you have a hexadecimal'
|
||||
. ' or binary mask please transform it to a deximal number first. The'
|
||||
. ' result of this modifier is a boolean value, telling whether the'
|
||||
. ' given mask applies to the numeric value in your source column'
|
||||
),
|
||||
'required' => true,
|
||||
));
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return 'Bitmask match (numeric)';
|
||||
}
|
||||
|
||||
public function transform($value)
|
||||
{
|
||||
$mask = (int) $this->getSetting('bitmask');
|
||||
return (((int) $value) & $mask) === $mask;
|
||||
}
|
||||
}
|
1
run.php
1
run.php
@ -31,6 +31,7 @@ $this->provideHook('director/PropertyModifier', $prefix . 'PropertyModifier\\Pro
|
||||
$this->provideHook('director/PropertyModifier', $prefix . 'PropertyModifier\\PropertyModifierExtractFromDN');
|
||||
$this->provideHook('director/PropertyModifier', $prefix . 'PropertyModifier\\PropertyModifierFromAdSid');
|
||||
$this->provideHook('director/PropertyModifier', $prefix . 'PropertyModifier\\PropertyModifierFromLatin1');
|
||||
$this->provideHook('director/PropertyModifier', $prefix . 'PropertyModifier\\PropertyModifierBitmask');
|
||||
|
||||
$this->provideHook('director/Job', $prefix . 'Job\\HousekeepingJob');
|
||||
$this->provideHook('director/Job', $prefix . 'Job\\ConfigJob');
|
||||
|
Loading…
x
Reference in New Issue
Block a user