function QueryTest::execute

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::execute()
  2. 10 core/modules/views/tests/modules/views_test_data/src/Plugin/views/query/QueryTest.php \Drupal\views_test_data\Plugin\views\query\QueryTest::execute()
  3. 11.x core/modules/views/tests/modules/views_test_data/src/Plugin/views/query/QueryTest.php \Drupal\views_test_data\Plugin\views\query\QueryTest::execute()

Overrides QueryPluginBase::execute

File

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

Class

QueryTest
Defines a query test plugin.

Namespace

Drupal\views_test_data\Plugin\views\query

Code

public function execute(ViewExecutable $view) {
    $result = [];
    foreach ($this->allItems as $element) {
        // Run all conditions on the element, and add it to the result if they
        // match.
        $match = TRUE;
        foreach ($this->conditions as $condition) {
            $match &= $this->match($element, $condition);
        }
        if ($match) {
            // If the query explicit defines fields to use, filter all others out.
            // Filter out fields
            if ($this->fields) {
                $element = array_intersect_key($element, $this->fields);
            }
            $result[] = new ResultRow($element);
        }
    }
    $this->view->result = $result;
}

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