protected function when(): bool|string
{
$defaultOperator = '=';
+ $defaultLogicalOperator = 'AND';
if (!$this->hasAttribute('when')) {
return false;
}
$res = [];
foreach ($when as $attr => $w) {
if (is_scalar($w)) {
- $w = ['values' => [$w], 'operator' => $defaultOperator];
+ $w = ['values' => [$w], 'operator' => $defaultOperator, 'logical_operator' => $defaultLogicalOperator];
} else {
if (isset($w['value'])) {
$w['values'] = $w['value'];
if (!isset($w['operator'])) {
$w['operator'] = $defaultOperator;
}
+ if (!isset($w['logical_operator'])) {
+ $w['logical_operator'] = $defaultLogicalOperator;
+ }
} else {
- $w = ['values' => $w, 'operator' => $defaultOperator];
+ $w = ['values' => $w, 'operator' => $defaultOperator, 'logical_operator' => $defaultLogicalOperator];
}
}
$res[$attr] = $w;
order = Math.min(order, condition.order);
}
});
- if (matchproperty === false) {
- match = false
- return false;
+
+ if (conditions.logical_operator === 'AND') {
+ match = match && matchproperty;
+ } else if (conditions.logical_operator === 'OR') {
+ match = match || matchproperty;
}
});
function checkCondition(condition, operator, val) {
try {
- if(val==='/index.html') {
+ if (val === '/index.html') {
console.log(condition, operator, val);
}
if (condition.id === undefined) {