protected function WebformSubmissionConditionsValidator::getConditionTargetsVisibilityRecursive in Webform 8.5
Same name and namespace in other branches
- 6.x src/WebformSubmissionConditionsValidator.php \Drupal\webform\WebformSubmissionConditionsValidator::getConditionTargetsVisibilityRecursive()
Recursively collect a conditions targets.
Parameters
array $conditions: An associative array containing conditions.
array $targets: An associative array keyed by target selectors with a boolean state.
1 call to WebformSubmissionConditionsValidator::getConditionTargetsVisibilityRecursive()
- WebformSubmissionConditionsValidator::getConditionTargetsVisibility in src/
WebformSubmissionConditionsValidator.php - Get the visibility state for all of conditions targets.
File
- src/
WebformSubmissionConditionsValidator.php, line 1061
Class
- WebformSubmissionConditionsValidator
- Webform submission conditions (#states) validator.
Namespace
Drupal\webformCode
protected function getConditionTargetsVisibilityRecursive(array $conditions, array &$targets = []) {
foreach ($conditions as $index => $value) {
if (is_int($index) && is_array($value) && WebformArrayHelper::isSequential($value)) {
// Recurse downward and get nested target element.
// NOTE: Nested conditions is not supported via the UI.
$this
->getConditionTargetsVisibilityRecursive($value, $targets);
}
elseif (is_string($value) && in_array($value, [
'and',
'or',
'xor',
])) {
// Skip AND, OR, or XOR operators.
continue;
}
elseif (is_int($index)) {
$selector = key($value);
$targets[$selector] = $selector;
}
else {
$selector = $index;
$targets[$selector] = $selector;
}
}
}