chg: [workflow:baseModule] New helper function and better usage of the `equals` filter operator

pull/8568/head
Sami Mokaddem 2022-08-05 14:32:05 +02:00
parent 94596b6bce
commit a2923513a5
No known key found for this signature in database
GPG Key ID: 164C473F627A06FA
1 changed files with 15 additions and 1 deletions

View File

@ -52,6 +52,17 @@ class WorkflowBaseModule
return $indexedParams;
}
protected function filtersEnabled($node): bool
{
$indexedFilters = $this->getFilters($node);
foreach ($indexedFilters as $k => $v) {
if ($v != '') {
return true;
}
}
return false;
}
protected function getFilters($node): array
{
$indexedFilters = [];
@ -170,7 +181,10 @@ class WorkflowBaseModule
protected function getItemsMatchingCondition($items, $value, $operator, $path)
{
foreach ($items as $i => $item) {
$subItem = $this->extractData($item, $path);
$subItem = $this->extractData($item, $path, $operator);
if (in_array($operator, ['equals', 'not_equals'])) {
$subItem = !empty($subItem) ? $subItem[0] : $subItem;
}
if (!$this->evaluateCondition($subItem, $operator, $value)) {
unset($items[$i]);
}