You are here

public function DatabaseTestController::pagerQueryEven in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/system/tests/modules/database_test/src/Controller/DatabaseTestController.php \Drupal\database_test\Controller\DatabaseTestController::pagerQueryEven()
  2. 9 core/modules/system/tests/modules/database_test/src/Controller/DatabaseTestController.php \Drupal\database_test\Controller\DatabaseTestController::pagerQueryEven()

Runs a pager query and returns the results.

This function does care about the page GET parameter, as set by the test HTTP call.

Return value

\Symfony\Component\HttpFoundation\JsonResponse

1 string reference to 'DatabaseTestController::pagerQueryEven'
database_test.routing.yml in core/modules/system/tests/modules/database_test/database_test.routing.yml
core/modules/system/tests/modules/database_test/database_test.routing.yml

File

core/modules/system/tests/modules/database_test/src/Controller/DatabaseTestController.php, line 51

Class

DatabaseTestController
Controller routines for database_test routes.

Namespace

Drupal\database_test\Controller

Code

public function pagerQueryEven($limit) {
  $query = $this->connection
    ->select('test', 't');
  $query
    ->fields('t', [
    'name',
  ])
    ->orderBy('age');

  // This should result in 2 pages of results.
  $query = $query
    ->extend(PagerSelectExtender::class)
    ->limit($limit);
  $names = $query
    ->execute()
    ->fetchCol();
  return new JsonResponse([
    'names' => $names,
  ]);
}