blob: d334f09fe7586accfe68e94ee747981cdc70f8c7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
<?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 decimal 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)
{
if ($value === null) {
return null;
}
$mask = (int) $this->getSetting('bitmask');
return (((int) $value) & $mask) === $mask;
}
}
|