function Condition::matchArray
Same name in other branches
- 9 core/lib/Drupal/Core/Config/Entity/Query/Condition.php \Drupal\Core\Config\Entity\Query\Condition::matchArray()
- 10 core/lib/Drupal/Core/Config/Entity/Query/Condition.php \Drupal\Core\Config\Entity\Query\Condition::matchArray()
- 11.x core/lib/Drupal/Core/Config/Entity/Query/Condition.php \Drupal\Core\Config\Entity\Query\Condition::matchArray()
Matches for an array representing one or more config paths.
Parameters
array $condition: The condition array as created by the condition() method.
array $data: The config array or part of it.
array $needs_matching: The list of config array keys needing a match. Can contain config keys and the * wildcard.
array $parents: The current list of parents.
Return value
bool TRUE when the condition matched to the data else FALSE.
1 call to Condition::matchArray()
- Condition::compile in core/
lib/ Drupal/ Core/ Config/ Entity/ Query/ Condition.php - Compiles this conditional clause.
File
-
core/
lib/ Drupal/ Core/ Config/ Entity/ Query/ Condition.php, line 112
Class
- Condition
- Defines the condition class for the config entity query.
Namespace
Drupal\Core\Config\Entity\QueryCode
protected function matchArray(array $condition, array $data, array $needs_matching, array $parents = []) {
$parent = array_shift($needs_matching);
if ($parent === '*') {
$candidates = array_keys($data);
}
else {
// Avoid a notice when calling match() later.
if (!isset($data[$parent])) {
$data[$parent] = NULL;
}
$candidates = [
$parent,
];
}
foreach ($candidates as $key) {
if ($needs_matching) {
if (is_array($data[$key])) {
$new_parents = $parents;
$new_parents[] = $key;
if ($this->matchArray($condition, $data[$key], $needs_matching, $new_parents)) {
return TRUE;
}
}
elseif ($condition['operator'] === 'IS NULL') {
return TRUE;
}
}
elseif ($this->match($condition, $data[$key])) {
return TRUE;
}
}
return FALSE;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.