public function QueryTest::match in Views (for Drupal 7) 8.3
Check a single condition for a single element.
Parameters
array $element: The element which should be checked.
array $condition: An associative array containing:
- field: The field to by, for example id.
- value: The expected value of the element.
- operator: The operator to compare the element value with the expected value.
Return value
bool Returns whether the condition matches with the element.
1 call to QueryTest::match()
- QueryTest::execute in tests/
views_test_data/ lib/ Drupal/ views_test_data/ Plugin/ views/ query/ QueryTest.php - Implements Drupal\views\Plugin\views\query\QueryPluginBase::execute().
File
- tests/
views_test_data/ lib/ Drupal/ views_test_data/ Plugin/ views/ query/ QueryTest.php, line 115 - Definition of Drupal\views_test_data\Plugin\views\query\QueryTest.
Class
- QueryTest
- Defines a query test plugin.
Namespace
Drupal\views_test_data\Plugin\views\queryCode
public function match($element, $condition) {
$value = $element[$condition['field']];
switch ($condition['operator']) {
case '=':
return $value == $condition['value'];
case 'IN':
return in_array($value, $condition['value']);
}
return FALSE;
}