function QueryTest::match

Same name in other branches
  1. 9 core/modules/views/tests/modules/views_test_data/src/Plugin/views/query/QueryTest.php \Drupal\views_test_data\Plugin\views\query\QueryTest::match()
  2. 8.9.x core/modules/views/tests/modules/views_test_data/src/Plugin/views/query/QueryTest.php \Drupal\views_test_data\Plugin\views\query\QueryTest::match()
  3. 10 core/modules/views/tests/modules/views_test_data/src/Plugin/views/query/QueryTest.php \Drupal\views_test_data\Plugin\views\query\QueryTest::match()

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 core/modules/views/tests/modules/views_test_data/src/Plugin/views/query/QueryTest.php
Executes query and fills associated view object with according values.

File

core/modules/views/tests/modules/views_test_data/src/Plugin/views/query/QueryTest.php, line 137

Class

QueryTest
Defines a query test plugin.

Namespace

Drupal\views_test_data\Plugin\views\query

Code

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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.