protected function Condition::match in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/lib/Drupal/Core/Config/Entity/Query/Condition.php \Drupal\Core\Config\Entity\Query\Condition::match()
Perform the actual matching.
Parameters
array $condition: The condition array as created by the condition() method.
string $value: The value to match against.
Return value
bool TRUE when matches else FALSE.
1 call to Condition::match()
- Condition::matchArray in core/
lib/ Drupal/ Core/ Config/ Entity/ Query/ Condition.php - Matches for an array representing one or more config paths.
File
- core/
lib/ Drupal/ Core/ Config/ Entity/ Query/ Condition.php, line 161 - Contains \Drupal\Core\Config\Entity\Query\Condition.
Class
- Condition
- Defines the condition class for the config entity query.
Namespace
Drupal\Core\Config\Entity\QueryCode
protected function match(array $condition, $value) {
if (isset($value)) {
// We always want a case-insensitive match.
if (!is_bool($value)) {
$value = Unicode::strtolower($value);
}
switch ($condition['operator']) {
case '=':
return $value == $condition['value'];
case '>':
return $value > $condition['value'];
case '<':
return $value < $condition['value'];
case '>=':
return $value >= $condition['value'];
case '<=':
return $value <= $condition['value'];
case '<>':
return $value != $condition['value'];
case 'IN':
return array_search($value, $condition['value']) !== FALSE;
case 'NOT IN':
return array_search($value, $condition['value']) === FALSE;
case 'STARTS_WITH':
return strpos($value, $condition['value']) === 0;
case 'CONTAINS':
return strpos($value, $condition['value']) !== FALSE;
case 'ENDS_WITH':
return substr($value, -strlen($condition['value'])) === (string) $condition['value'];
case 'IS NOT NULL':
return TRUE;
case 'IS NULL':
return FALSE;
default:
throw new QueryException('Invalid condition operator.');
}
}
return $condition['operator'] === 'IS NULL';
}