Skip to content

Commit

Permalink
use PaginatorInterface instead of Paginator. Update changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
garak committed Dec 15, 2020
1 parent a269a96 commit 7ac5488
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 14 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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*

Expand Down
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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:
Expand Down Expand Up @@ -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"
Expand All @@ -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.
Expand Down
5 changes: 2 additions & 3 deletions src/Definition/AbstractPaginatorAware.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Knp\Bundle\PaginatorBundle\Definition;

use Knp\Component\Pager\Paginator;
use Knp\Component\Pager\PaginatorInterface;

/**
Expand All @@ -11,7 +10,7 @@
abstract class AbstractPaginatorAware implements PaginatorAwareInterface
{
/**
* @var Paginator
* @var PaginatorInterface
*/
private $paginator;

Expand All @@ -28,7 +27,7 @@ public function setPaginator(PaginatorInterface $paginator): PaginatorAwareInter
/**
* Returns the KnpPaginator instance.
*/
public function getPaginator(): Paginator
public function getPaginator(): PaginatorInterface
{
return $this->paginator;
}
Expand Down
7 changes: 4 additions & 3 deletions src/Definition/PaginatorAwareInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
4 changes: 2 additions & 2 deletions src/Helper/Processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down

0 comments on commit 7ac5488

Please sign in to comment.