diff --git a/CHANGELOG.md b/CHANGELOG.md index 63eb36ef..66d4b873 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,9 @@ - Added support for php 8 - Added support for Material design in sortable +### BC Breaks +- PaginationAwareInterface is now using PaginationInterface instead of Pagination + # 5.3.0 *Released at 2020-07-21* diff --git a/README.md b/README.md index a95f39f6..329c1cc4 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Friendly Symfony paginator to paginate everything [![Build Status](https://travis-ci.org/KnpLabs/KnpPaginatorBundle.svg?branch=master)](https://travis-ci.org/KnpLabs/KnpPaginatorBundle) Generally this bundle is based on [Knp Pager component][knp_component_pager]. This -component introduces a different way for pagination handling. You can read more about the +component introduces a different way of pagination handling. You can read more about the internal logic on the given documentation link. [![knpbundles.com](http://knpbundles.com/KnpLabs/KnpPaginatorBundle/badge-short)](http://knpbundles.com/KnpLabs/KnpPaginatorBundle) @@ -16,14 +16,14 @@ suitable to paginate **ODM MongoDB** and **ORM 2.0** queries ## Latest updates -For notes about latest changes please read [`CHANGELOG`](https://github.com/KnpLabs/KnpPaginatorBundle/blob/master/CHANGELOG.md), +For notes about the latest changes please read [`CHANGELOG`](https://github.com/KnpLabs/KnpPaginatorBundle/blob/master/CHANGELOG.md), for required changes in your code please read [`UPGRADE`](https://github.com/KnpLabs/KnpPaginatorBundle/blob/master/docs/upgrade.md) -chapter of documentation. +chapter of the documentation. ## Requirements: - Knp Pager component `>=2.0`. -- KnpPaginatorBundle's master compatible with Symfony `>=4.3` versions. +- KnpPaginatorBundle's master is compatible with Symfony `>=4.4` versions. - Twig `>=2.0` version is required if you use twig templating engine. ## Features: @@ -233,8 +233,8 @@ translationCount and translationParameters can be combined. ``` ### Adding translation files -You can also override translations by creating translation file in the following name format: `domain.locale.format`. -So, to create translation file for this bundle you need to create for instance `KnpPaginatorBundle.tr.yaml` file under `project_root/translations/` +You can also override translations by creating a translation file in the following name format: `domain.locale.format`. +So, to create a translation file for this bundle you need to create for instance `KnpPaginatorBundle.tr.yaml` file under `project_root/translations/` and add your translations there: ```yaml label_previous: "Önceki" @@ -257,6 +257,9 @@ It defaults to `knp_paginator`. The class that receives the KnpPaginator service must implement `Knp\Bundle\PaginatorBundle\Definition\PaginatorAwareInterface`. If you're too lazy you can also just extend the `Knp\Bundle\PaginatorBundle\Definition\PaginatorAware` base class. +> **⚠ Warning** using `PaginatorAwareInterface` is discouraged, and could be removed in a future version. You should not rely on setter +> injection, but only on proper constructor injection. Using Symfony built-in autowiring mechanism is the suggested way to go. + #### Lazy service The `knp_paginator` service will be created lazily if the package `symfony/proxy-manager-bridge` is installed. diff --git a/src/Definition/AbstractPaginatorAware.php b/src/Definition/AbstractPaginatorAware.php index 9b5ce0b3..4fb825f6 100644 --- a/src/Definition/AbstractPaginatorAware.php +++ b/src/Definition/AbstractPaginatorAware.php @@ -2,7 +2,7 @@ namespace Knp\Bundle\PaginatorBundle\Definition; -use Knp\Component\Pager\Paginator; +use Knp\Component\Pager\PaginatorInterface; /** * This is a base class that can be extended if you're too lazy to implement PaginatorAwareInterface yourself. @@ -10,14 +10,14 @@ abstract class AbstractPaginatorAware implements PaginatorAwareInterface { /** - * @var Paginator + * @var PaginatorInterface */ private $paginator; /** * Sets the KnpPaginator instance. */ - public function setPaginator(Paginator $paginator): PaginatorAwareInterface + public function setPaginator(PaginatorInterface $paginator): PaginatorAwareInterface { $this->paginator = $paginator; @@ -27,7 +27,7 @@ public function setPaginator(Paginator $paginator): PaginatorAwareInterface /** * Returns the KnpPaginator instance. */ - public function getPaginator(): Paginator + public function getPaginator(): PaginatorInterface { return $this->paginator; } diff --git a/src/Definition/PaginatorAwareInterface.php b/src/Definition/PaginatorAwareInterface.php index 2cbeb8cb..cc0996d7 100644 --- a/src/Definition/PaginatorAwareInterface.php +++ b/src/Definition/PaginatorAwareInterface.php @@ -2,17 +2,18 @@ namespace Knp\Bundle\PaginatorBundle\Definition; -use Knp\Component\Pager\Paginator; +use Knp\Component\Pager\PaginatorInterface; /** * Interface PaginatorAwareInterface. * - * PaginatorAwareInterface should be implemented by classes that depend on a KnpPaginator service. + * PaginatorAwareInterface can be implemented by classes that depend on a KnpPaginator service. + * You should avoid this solution: use autowiring instead. */ interface PaginatorAwareInterface { /** * Sets the KnpPaginator instance. */ - public function setPaginator(Paginator $paginator): self; + public function setPaginator(PaginatorInterface $paginator): self; } diff --git a/src/Helper/Processor.php b/src/Helper/Processor.php index e1b8068a..a929f1b5 100644 --- a/src/Helper/Processor.php +++ b/src/Helper/Processor.php @@ -18,12 +18,12 @@ final class Processor /** * @var UrlGeneratorInterface */ - protected $router; + private $router; /** * @var TranslatorInterface */ - protected $translator; + private $translator; public function __construct(UrlGeneratorInterface $router, TranslatorInterface $translator) {