diff --git a/README.md b/README.md
index 4f71c1d..cdee9f4 100644
--- a/README.md
+++ b/README.md
@@ -35,7 +35,8 @@ Features
Styles
------
- _Standard_ - alike standard Drupal pager theme
-- _Progressive_ - provides links to pages progressively more distant from current
+- _Progressive_ - provides links to pages progressively more distant from
+ current
- _Adaptive_ - provides links to pages following an adaptive logic
- _Basic_ - similar to Views mini pager
- _Multipane_ - a multi-pane (left, center, and right) pager style, enabling
@@ -48,14 +49,16 @@ Requirements
Instructions
------------
-- Download the module running ```composer require drupal/pagerer:^3``` from the command line.
+- Download the module running ```composer require drupal/pagerer:^3``` from the
+ command line.
- Enable the module.
- Check the Configuration page to setup.
- Create and configure any number of 'preset' pagers.
- Select a preset to use as a general replacement of Drupal core pager, or
use a preset as a pager in Views.
-- to change URL querystrings to start page count from one, go to the _URL settings_
- tab, select the _URL querystring_ checkbox, and _One-based_ from _Page index base_.
+- to change URL querystrings to start page count from one, go to the
+ _URL settings_ tab, select the _URL querystring_ checkbox, and _One-based_
+ from _Page index base_.
URL querystring override
------------------------
@@ -253,7 +256,8 @@ The variables defined for this theme are the following:
- ```config```: (optional) an associative array of configuration elements to be
passed to the style plugin.
-The content of the ```config``` variable depends on the style plugin requirements.
+The content of the ```config``` variable depends on the style plugin
+requirements.
Each plugin manages its own default values, that get merged with the values
passed by the config variable upon rendering of the pager.
@@ -262,8 +266,8 @@ passed by the config variable upon rendering of the pager.
Applies to styles: _standard, progressive, adaptive_.
- ```display```: can take the values "pages", "items", "item_ranges". Determines
whether to display pages, or items, or item ranges.
-- ```display_restriction```: it allows to restrict showing the pager based on the
- actual number of pages in the result set. It takes the minimum number of
+- ```display_restriction```: it allows to restrict showing the pager based on
+ the actual number of pages in the result set. It takes the minimum number of
pages that the result set need to have to have a pager rendered:
- 2 (pager is shown if the result set is made of at least two pages),
- 1 (pager is shown even if the result set is made of one page only),
@@ -278,13 +282,13 @@ passed by the config variable upon rendering of the pager.
Applies to styles: _standard, progressive, adaptive, mini, basic_.
- ```prefix_display```: Determines whether to render a text label (e.g. "Page:")
before the actual pager.
-- ```suffix_display```: Determines whether to render a text label (e.g. "of @total")
- after the actual pager.
+- ```suffix_display```: Determines whether to render a text label
+ (e.g. "of @total") after the actual pager.
- ```separator_display```: A flag to indicate if a text separator has to be
included between contiguous pages.
Applies to styles: _standard, progressive, adaptive, scrollpane_.
-- ```breaker_display```: A flag to indicate if a text element (e.g. "...") has to
- be introduced when the pages sequence breaks.
+- ```breaker_display```: A flag to indicate if a text element (e.g. "...") has
+ to be introduced when the pages sequence breaks.
Applies to styles: _standard, progressive, adaptive_.
- ```first_link```: Determines when to render a link to the first page (e.g.
"<< First"). Options are:
@@ -310,26 +314,27 @@ passed by the config variable upon rendering of the pager.
'neighborhood' as "absolute" page numbers (or items/item ranges) or as
"relative" offsets from current (e.g. "+10 +100 +1000").
Applies to styles: _progressive, adaptive_.
-- ```factors```: Comma delimited string of factors to use to determine progressive
- links.
+- ```factors```: Comma delimited string of factors to use to determine
+ progressive links.
Applies to styles: _progressive_.
- ```widget_resize```: Determines if the input box width should be calculated
dynamically based on the width of the string of the last page/item number.
Set to 'false' to keep a fixed width as set by CSS styling. Default: 'true'.
Applies to styles: _mini_.
-- ```widget_button```: Determines if a button has to be shown aside the input box,
- clicking which the page relocation will be triggered. Options are:
+- ```widget_button```: Determines if a button has to be shown aside the input
+ box, clicking which the page relocation will be triggered. Options are:
- "no" (page relocation will only occur by pressing the 'return' key on the
keyboard),
- "yes" (button is shown, and button is styled via CSS),
- "auto" (button height is automatically resized to match the input box
height).
Applies to styles: _mini_.
-- ```slider_width```: The width of the slider bar. Expressed in 'em' for CSS styling.
+- ```slider_width```: The width of the slider bar. Expressed in 'em' for CSS
+ styling.
Leave blank to default to CSS settings.
Applies to styles: _slider_.
-- ```slider_action```: Determines how the page relocation should be triggered after
- it has been selected through the jQuery slider. Options are:
+- ```slider_action```: Determines how the page relocation should be triggered
+ after it has been selected through the jQuery slider. Options are:
- "tickmark" (page relocation only occurs after user clicks a tickmark on the
slider handle),
- "timeout" (page relocation occurs after a grace time has elapsed),
@@ -337,62 +342,64 @@ passed by the config variable upon rendering of the pager.
accuracy of the slider, i.e. if there are at least 3 pixels between
contiguous pages).
Applies to styles: _slider_.
-- ```slider_action_timeout```: The grace time (in milliseconds) to wait before the
- page is relocated, in case "timeout" slider_action method is selected for
+- ```slider_action_timeout```: The grace time (in milliseconds) to wait before
+ the page is relocated, in case "timeout" slider_action method is selected for
the jQuery slider. "0" will trigger relocation immediately.
Applies to styles: _slider_.
-- ```slider_navigation_icons```: Determines whether to display +/- navigation icons
- on the sides of the jQuery slider. Options are "yes", "no", "auto" (the icons
- are automatically displayed based on the accuracy of the slider).
+- ```slider_navigation_icons```: Determines whether to display +/- navigation
+ icons on the sides of the jQuery slider. Options are "yes", "no", "auto" (the
+ icons are automatically displayed based on the accuracy of the slider).
Applies to styles: _slider_.
- ```tags```: an associative array of textual elements to be used to render the
pager, see details in section below.
- The ```tags``` variable in Pagerer style configuration is an associative array of
- tags to be used to render any of the textual elements of the pager.
+ The ```tags``` variable in Pagerer style configuration is an associative array
+ of tags to be used to render any of the textual elements of the pager.
- - ```page_breaker```: Text to render a break in the page sequence. Defaults to an
- ellipsis (...).
+ - ```page_breaker```: Text to render a break in the page sequence. Defaults to
+ an ellipsis (...).
Applies to styles: _standard, progressive, adaptive_.
- ```page_separator```: Text to fill between contiguous pages, if
'separator_display' is set on. Defaults to a vertical bar (|).
separators are rendered.
Applies to styles: _standard, progressive, adaptive, scrollpane_.
- - ```pages```: An associative array of text elements to be used if 'display' is
- set to "pages". See below.
- - ```items```: An associative array of text elements to be used if 'display' is
- set to "items". See below.
- - ```item_ranges```: An associative array of text elements to be used if 'display' is
- set to "item_ranges". See below.
-
- Each of ```tags.pages```, ```tags.items``` and ```tags.item_ranges``` indicate how the relative
- text should be rendered in the pager, based on the current 'display' mode
- selected. Regardless of the display mode, the following placeholders will be
- resolved at runtime with live data:
+ - ```pages```: An associative array of text elements to be used if 'display'
+ is set to "pages". See below.
+ - ```items```: An associative array of text elements to be used if 'display'
+ is set to "items". See below.
+ - ```item_ranges```: An associative array of text elements to be used if
+ 'display' is set to "item_ranges". See below.
+
+ Each of ```tags.pages```, ```tags.items``` and ```tags.item_ranges``` indicate
+ how the relative text should be rendered in the pager, based on the current
+ 'display' mode selected. Regardless of the display mode, the following
+ placeholders will be resolved at runtime with live data:
- ```@number``` - the target page number.
- - ```@offset``` - the offset of the target page from the current one, in pages.
+ - ```@offset``` - the offset of the target page from the current one, in
+ pages.
- ```@total``` - total number of pages in the pager.
- ```@item``` - the number of the first item in the target page.
- ```@item_low``` - the number of the first item in the target page.
- ```@item_high``` - the number of the last item in the target page.
- - ```@item_offset``` - the offset of the target page from the current one, in items.
+ - ```@item_offset``` - the offset of the target page from the current one, in
+ items.
- ```@total_items``` - total number of items in the pager.
-- ```prefix_label```: Text to use to render a label (e.g. "Page") in front of the
- pager.
-- ```suffix_label```: Text to use to render a label (e.g. "of @number") after the
- pager.
+- ```prefix_label```: Text to use to render a label (e.g. "Page") in front of
+ the pager.
+- ```suffix_label```: Text to use to render a label (e.g. "of @number") after
+ the pager.
- ```page_current```: Text to use to render the current page/item/item range.
- ```page_previous```: Text to use to render a page/item/item range that is
before the current page.
- ```page_next```: Text to use to render a page/item/item range that is
after the current page.
-- ```page_previous_relative```: Text to use to render the link to a previous page
- outside of the neighborhood (e.g. "-100").
+- ```page_previous_relative```: Text to use to render the link to a previous
+ page outside of the neighborhood (e.g. "-100").
Applies to styles: _progressive, adaptive_.
-- ```page_next_relative```: Text to use to render the link to a next page outside
- of the neighborhood (e.g. "+100").
+- ```page_next_relative```: Text to use to render the link to a next page
+ outside of the neighborhood (e.g. "+100").
Applies to styles: _progressive, adaptive_.
- ```first```: Text to use to render the link to the first page (e.g. "<<
first").
@@ -400,10 +407,10 @@ passed by the config variable upon rendering of the pager.
(e.g. "< Previous").
- ```next```: Text to use to render the link to the next page (e.g. "Next >").
- ```last```: Text to use to render the link to the last page (e.g. "Last >>").
-- ```pageset_empty```: Text to use to render the current page in the pager in case
- there are no items in the pageset (e.g. 'No pages to display').
-- ```page_current_title```: Help text used when hovering the current page link (e.g.
- 'Current page').
+- ```pageset_empty```: Text to use to render the current page in the pager in
+ case there are no items in the pageset (e.g. 'No pages to display').
+- ```page_current_title```: Help text used when hovering the current page link
+ (e.g. 'Current page').
- ```page_title```: Help text used when hovering a page link (e.g. 'Go to page
@number').
- ```first_title```: Help text used when hovering a first page link (e.g. 'Go to
@@ -429,11 +436,11 @@ passed by the config variable upon rendering of the pager.
- ```widget_title```: Help text used when hovering the direct input widget (e.g.
'Enter page, then press Return.').
Applies to styles: _mini_.
-- ```slider_title```: Help text used when hovering the slider (e.g. 'Drag the handle
- to the page required.').
+- ```slider_title```: Help text used when hovering the slider (e.g. 'Drag the
+ handle to the page required.').
Applies to styles: _slider_.
-- ```slider_tickmark_title```: Help text appended to the slider help when user is
- expected to click on the tickmark to start page relocation. Defaults to:
+- ```slider_tickmark_title```: Help text appended to the slider help when user
+ is expected to click on the tickmark to start page relocation. Defaults to:
'Then, click on the tickmark.'.
Applies to styles: _slider_.
@@ -441,11 +448,11 @@ passed by the config variable upon rendering of the pager.
pagerer
-------
-The ```pagerer``` theme itself is more a container of individual ```pagerer_base```
-themes. The theme to be used in each pane (left, center, and right) and its
-variables are either retrieved from a defined PagererPreset configuration
-entity through its 'data' property, or passed to a {position}_pane variable
-of the pagerer theme.
+The ```pagerer``` theme itself is more a container of individual
+```pagerer_base``` themes. The theme to be used in each pane
+(left, center, and right) and its variables are either retrieved from a defined
+PagererPreset configuration entity through its 'data' property, or passed to a
+{position}_pane variable of the pagerer theme.
- ```element```: same as Drupal, an optional integer to distinguish between
multiple pagers on one page.
@@ -460,8 +467,8 @@ of the pagerer theme.
specified along the preset variable.
- ```panes```: an associative array of 'left'|'center'|'right', where each key
is an associative array of:
- - ```style```: the style plugin to pass to _pagerer_base_ theme: 'standard' |
- 'progressive' | 'scrollpane' | 'adaptive' | 'mini' | 'slider' | 'none'
+ - ```style```: the style plugin to pass to _pagerer_base_ theme: 'standard'
+ | 'progressive' | 'scrollpane' | 'adaptive' | 'mini' | 'slider' | 'none'
- ```config```: the configuration array to pass to _pagerer_base_ theme
Example:
diff --git a/pagerer_example/src/Controller/PagererExampleController.php b/pagerer_example/src/Controller/PagererExampleController.php
index f29ed21..6bb92db 100644
--- a/pagerer_example/src/Controller/PagererExampleController.php
+++ b/pagerer_example/src/Controller/PagererExampleController.php
@@ -3,12 +3,68 @@
namespace Drupal\pagerer_example\Controller;
use Drupal\Core\Controller\ControllerBase;
+use Symfony\Component\DependencyInjection\ContainerInterface;
+use Drupal\Core\Extension\ModuleExtensionList;
+use Drupal\Core\Database\Connection;
+use Drupal\pagerer\Plugin\PagererStyleManager;
/**
* Controller class for Pagerer example.
*/
class PagererExampleController extends ControllerBase {
+ /**
+ * The module extensions list.
+ *
+ * @var \Drupal\Core\Extension\ModuleExtensionList
+ */
+ protected $moduleExtensionList;
+
+ /**
+ * The database service.
+ *
+ * @var \Drupal\Core\Database\Connection
+ */
+ protected $database;
+
+ /**
+ * The pagerer service.
+ *
+ * @var \Drupal\pagerer\Plugin\PagererStyleManager
+ */
+ protected $pagerer;
+
+ /**
+ * PagererExampleController constructor.
+ *
+ * @param \Drupal\Core\Extension\ModuleExtensionList $module_extension_list
+ * The module extensions list.
+ * @param \Drupal\Core\Database\Connection $database
+ * The database service.
+ * @param \Drupal\pagerer\Plugin\PagererStyleManager $pagerer
+ * The pagerer service.
+ */
+ public function __construct(
+ ModuleExtensionList $module_extension_list,
+ Connection $database,
+ PagererStyleManager $pagerer
+ ) {
+ $this->moduleExtensionList = $module_extension_list;
+ $this->database = $database;
+ $this->pagerer = $pagerer;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function create(ContainerInterface $container) {
+ return new static(
+ $container->get('extension.list.module'),
+ $container->get('database'),
+ $container->get('pagerer.style.manager')
+ );
+ }
+
/**
* Get pagerer example page title.
*
@@ -17,7 +73,7 @@ class PagererExampleController extends ControllerBase {
*/
public function examplePageTitle(): string {
// Set the page title to show current Pagerer version.
- $module_info = \Drupal::service('extension.list.module')->getExtensionInfo('pagerer');
+ $module_info = $this->moduleExtensionList->getExtensionInfo('pagerer');
return $this->t("Pagerer @version - example page", ['@version' => $module_info['version'] ?? 'dev']);
}
@@ -35,7 +91,7 @@ class PagererExampleController extends ControllerBase {
['data' => 'type'],
['data' => 'timestamp'],
];
- $query_0 = \Drupal::database()->select('watchdog', 'd')->extend('Drupal\Core\Database\Query\PagerSelectExtender')->element(0);
+ $query_0 = $this->database->select('watchdog', 'd')->extend('Drupal\Core\Database\Query\PagerSelectExtender')->element(0);
$result_0 = $query_0
->fields('d', ['wid', 'type', 'timestamp'])
->limit(5)
@@ -51,7 +107,7 @@ class PagererExampleController extends ControllerBase {
['data' => 'collection'],
['data' => 'name'],
];
- $query_1 = \Drupal::database()->select('key_value', 'd')->extend('Drupal\Core\Database\Query\PagerSelectExtender')->element(1);
+ $query_1 = $this->database->select('key_value', 'd')->extend('Drupal\Core\Database\Query\PagerSelectExtender')->element(1);
$result_1 = $query_1
->fields('d', ['collection', 'name'])
->limit(10)
@@ -68,7 +124,7 @@ class PagererExampleController extends ControllerBase {
['data' => 'name'],
['data' => 'path'],
];
- $query_2 = \Drupal::database()->select('router', 'd')->extend('Drupal\Core\Database\Query\PagerSelectExtender')->element(2);
+ $query_2 = $this->database->select('router', 'd')->extend('Drupal\Core\Database\Query\PagerSelectExtender')->element(2);
$result_2 = $query_2
->fields('d', ['name', 'path'])
->limit(5)
@@ -80,7 +136,7 @@ class PagererExampleController extends ControllerBase {
}
// Get the available pagerer style plugins.
- $plugin_definitions = \Drupal::service('pagerer.style.manager')->getDefinitions();
+ $plugin_definitions = $this->pagerer->getDefinitions();
// Put the 'standard' plugin on top.
if (isset($plugin_definitions['standard'])) {
$standard = $plugin_definitions['standard'];
diff --git a/src/Form/PagererUrlConfigForm.php b/src/Form/PagererUrlConfigForm.php
index 9ea9848..71141fb 100644
--- a/src/Form/PagererUrlConfigForm.php
+++ b/src/Form/PagererUrlConfigForm.php
@@ -74,7 +74,8 @@ class PagererUrlConfigForm extends ConfigFormBase {
*/
public function validateForm(array &$form, FormStateInterface $form_state) {
parent::validateForm($form, $form_state);
- if (in_array((string) $form_state->getValue('querystring_key'), ['page', 'page_ak'])) {
+ $accepted_query_string_keys = ['page', 'page_ak'];
+ if (in_array((string) $form_state->getValue('querystring_key'), $accepted_query_string_keys)) {
$form_state->setErrorByName(
'querystring_key',
$this->t("'page' and 'page_ak' can not be used for replacement. Choose a different key name."));
diff --git a/src/Pagerer.php b/src/Pagerer.php
index 95a96bb..d384631 100644
--- a/src/Pagerer.php
+++ b/src/Pagerer.php
@@ -3,7 +3,6 @@
namespace Drupal\pagerer;
use Drupal\Core\Pager\Pager;
-use Symfony\Component\Routing\Route;
/**
* Pagerer pager value object.
@@ -24,9 +23,9 @@ class Pagerer extends Pager {
/**
* The route name.
*
- * @var \Symfony\Component\Routing\Route|string
+ * @var string
*/
- protected Route|string $routeName;
+ protected string $routeName;
/**
* The route parameters.
@@ -45,23 +44,23 @@ class Pagerer extends Pager {
/**
* Gets the route name for this pager.
*
- * @return \Symfony\Component\Routing\Route|string
+ * @return string
* The route name.
*/
- public function getRouteName(): Route|string {
+ public function getRouteName(): string {
return $this->routeName;
}
/**
* Sets the route name for this pager.
*
- * @param \Symfony\Component\Routing\Route|string $route_name
+ * @param string $route_name
* The route name.
*
* @return self
* Self.
*/
- public function setRouteName(Route|string $route_name): self {
+ public function setRouteName(string $route_name): self {
$this->routeName = $route_name;
return $this;
}
diff --git a/src/Plugin/PagererStyleManager.php b/src/Plugin/PagererStyleManager.php
index bd94e02..0f41fbc 100644
--- a/src/Plugin/PagererStyleManager.php
+++ b/src/Plugin/PagererStyleManager.php
@@ -16,7 +16,7 @@ use Drupal\pagerer\Plugin\Annotation\PagererStyle as PagererStyleAnnotation;
class PagererStyleManager extends DefaultPluginManager implements PagererStyleManagerInterface {
/**
- *
+ * {@inheritdoc}
*/
public function __construct(
\Traversable $namespaces,
diff --git a/src/Plugin/pagerer/PagererStyleBase.php b/src/Plugin/pagerer/PagererStyleBase.php
index 995c2c3..d93f563 100644
--- a/src/Plugin/pagerer/PagererStyleBase.php
+++ b/src/Plugin/pagerer/PagererStyleBase.php
@@ -71,8 +71,8 @@ abstract class PagererStyleBase extends PluginBase implements PagererStyleInterf
*/
public function __construct(
array $configuration,
- string $plugin_id,
- mixed $plugin_definition,
+ $plugin_id,
+ $plugin_definition,
protected TypedConfigManager $typedConfigManager,
protected ConfigFactoryInterface $configFactory,
protected PagerManagerInterface $pagerManager
diff --git a/src/Plugin/views/pager/Pagerer.php b/src/Plugin/views/pager/Pagerer.php
index b04865f..751e8d5 100644
--- a/src/Plugin/views/pager/Pagerer.php
+++ b/src/Plugin/views/pager/Pagerer.php
@@ -34,11 +34,15 @@ class Pagerer extends Full implements ContainerFactoryPluginInterface {
/**
* The list of pagerer presets.
+ *
+ * @var \Drupal\Core\Entity\EntityListBuilderInterface
*/
protected EntityListBuilderInterface $presetsList;
/**
* The Pagerer preset entity storage.
+ *
+ * @var \Drupal\Core\Entity\EntityStorageInterface
*/
protected EntityStorageInterface $presetStorage;
@@ -60,8 +64,8 @@ class Pagerer extends Full implements ContainerFactoryPluginInterface {
*/
public function __construct(
array $configuration,
- string $plugin_id,
- mixed $plugin_definition,
+ $plugin_id,
+ $plugin_definition,
PagerManagerInterface $pager_manager,
PagerParametersInterface $pager_parameters,
EntityTypeManagerInterface $entityTypeManager
diff --git a/tests/modules/pagerer_test/pagerer_test.module b/tests/modules/pagerer_test/pagerer_test.module
index f965b0c..b2998c4 100644
--- a/tests/modules/pagerer_test/pagerer_test.module
+++ b/tests/modules/pagerer_test/pagerer_test.module
@@ -15,7 +15,7 @@ function pagerer_test_preprocess_pagerer_base(&$variables) {
return;
}
- foreach ($variables['items']['pages'] as $index => &$pager_item) {
+ foreach ($variables['items']['pages'] as &$pager_item) {
$pager_item['attributes']['pager-test'] = 'yes';
}
unset($pager_item);
diff --git a/tests/src/Functional/PagererTest.php b/tests/src/Functional/PagererTest.php
index 46ef632..0a8142a 100644
--- a/tests/src/Functional/PagererTest.php
+++ b/tests/src/Functional/PagererTest.php
@@ -567,7 +567,6 @@ class PagererTest extends BrowserTestBase {
// Loop through test sets.
foreach (['page', 'pg_0', 'px_1'] as $set) {
- $match_querystring = 'expected_querystring_' . $set;
switch ($set) {
case 'core':
// Run with default: 'page' and 0-based page numbers.
diff --git a/tests/src/FunctionalJavascript/CorePagerReplacePaginationAJAXTest.php b/tests/src/FunctionalJavascript/CorePagerReplacePaginationAJAXTest.php
index b16e273..7624a2f 100644
--- a/tests/src/FunctionalJavascript/CorePagerReplacePaginationAJAXTest.php
+++ b/tests/src/FunctionalJavascript/CorePagerReplacePaginationAJAXTest.php
@@ -3,6 +3,7 @@
namespace Drupal\Tests\pagerer\FunctionalJavascript;
use Drupal\Tests\views\FunctionalJavascript\PaginationAJAXTest;
+use Drupal\Core\StringTranslation\StringTranslationTrait;
/**
* Tests the click sorting AJAX functionality of Views exposed forms.
@@ -10,6 +11,7 @@ use Drupal\Tests\views\FunctionalJavascript\PaginationAJAXTest;
* @group Pagerer
*/
class CorePagerReplacePaginationAJAXTest extends PaginationAJAXTest {
+ use StringTranslationTrait;
/**
* The URL for Pagerer admin UI page.
@@ -33,7 +35,7 @@ class CorePagerReplacePaginationAJAXTest extends PaginationAJAXTest {
$this->drupalGet($this->pagererAdmin . '/preset/add');
$this->submitForm([
'label' => 'core_replace',
- ], t('Create'));
+ ], $this->t('Create'));
// Make 'core_replace' pagerer preset the global pager replacement.
\Drupal::configFactory()->getEditable('pagerer.settings')