public function PagerTestController::queryParameters in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/system/tests/modules/pager_test/src/Controller/PagerTestController.php \Drupal\pager_test\Controller\PagerTestController::queryParameters()
Returns a pager with 'parameters' variable.
The 'pager_calls' parameter counts the calls to the pager, subsequent to the initial call.
1 string reference to 'PagerTestController::queryParameters'
- pager_test.routing.yml in core/
modules/ system/ tests/ modules/ pager_test/ pager_test.routing.yml - core/modules/system/tests/modules/pager_test/pager_test.routing.yml
File
- core/
modules/ system/ tests/ modules/ pager_test/ src/ Controller/ PagerTestController.php, line 23 - Contains \Drupal\pager_test\Controller\PagerTestController.
Class
- PagerTestController
- Controller routine for testing the pager.
Namespace
Drupal\pager_test\ControllerCode
public function queryParameters() {
// Example query.
$header_0 = array(
array(
'data' => 'wid',
),
array(
'data' => 'type',
),
array(
'data' => 'timestamp',
),
);
$query_0 = db_select('watchdog', 'd')
->extend('Drupal\\Core\\Database\\Query\\PagerSelectExtender')
->element(0);
$query_0
->fields('d', array(
'wid',
'type',
'timestamp',
));
$result_0 = $query_0
->limit(5)
->orderBy('d.wid')
->execute();
$rows_0 = array();
foreach ($result_0 as $row) {
$rows_0[] = array(
'data' => (array) $row,
);
}
$build['pager_table_0'] = array(
'#theme' => 'table',
'#header' => $header_0,
'#rows' => $rows_0,
'#empty' => $this
->t("There are no watchdog records found in the db"),
);
// Counter of calls to the current pager.
$query_params = pager_get_query_parameters();
$pager_calls = isset($query_params['pager_calls']) ? $query_params['pager_calls'] ? $query_params['pager_calls'] : 0 : 0;
$build['l_pager_pager_0'] = array(
'#markup' => $this
->t('Pager calls: @pager_calls', array(
'@pager_calls' => $pager_calls,
)),
);
// Pager.
$build['pager_pager_0'] = array(
'#type' => 'pager',
'#element' => 0,
'#parameters' => array(
'pager_calls' => ++$pager_calls,
),
'#pre_render' => [
'Drupal\\pager_test\\Controller\\PagerTestController::showPagerCacheContext',
],
);
return $build;
}