pagerer_test.module in Pagerer 8.2
Same filename and directory in other branches
Hook implementations for this module.
File
tests/modules/pagerer_test/pagerer_test.moduleView source
<?php
/**
* @file
* Hook implementations for this module.
*/
/**
* Implements hook_preprocess_HOOK().
*/
function pagerer_test_preprocess_pagerer_base(&$variables) {
// Check if pager is needed; if not, return immediately.
$pager = \Drupal::service('pager.manager')
->getPager($variables['pager']['#element']);
if ($pager
->getTotalPages() <= 1) {
return;
}
foreach ($variables['items']['pages'] as $index => &$pager_item) {
$pager_item['attributes']['pager-test'] = 'yes';
}
unset($pager_item);
foreach ([
'first',
'previous',
'next',
'last',
] as $special_pager_item) {
if (isset($variables['items'][$special_pager_item])) {
$variables['items'][$special_pager_item]['attributes']['pager-test'] = $special_pager_item;
}
}
}
Functions
Name | Description |
---|---|
pagerer_test_preprocess_pagerer_base | Implements hook_preprocess_HOOK(). |