From f8047ba5bdabe7d32bcaf632607e69962fdb47b9 Mon Sep 17 00:00:00 2001 From: core23 Date: Mon, 15 Mar 2021 18:00:07 +0100 Subject: [PATCH] Bump sonata-project/datagrid-bundle --- composer.json | 2 +- src/Entity/BlockManager.php | 12 +++--------- src/Entity/DashboardManager.php | 12 +++--------- src/Model/BlockManagerInterface.php | 8 ++++++-- src/Model/DashboardManagerInterface.php | 7 +++++-- 5 files changed, 18 insertions(+), 23 deletions(-) diff --git a/composer.json b/composer.json index bd0118f..ee60bfd 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,7 @@ "sonata-project/admin-bundle": "^3.58", "sonata-project/block-bundle": "^3.18", "sonata-project/cache-bundle": "^2.4.2", - "sonata-project/datagrid-bundle": "^2.3", + "sonata-project/datagrid-bundle": "^3.3", "sonata-project/doctrine-extensions": "^1.10.1", "sonata-project/form-extensions": "^0.1 || ^1.4", "symfony/config": "^4.4", diff --git a/src/Entity/BlockManager.php b/src/Entity/BlockManager.php index 549afaf..59b17fd 100644 --- a/src/Entity/BlockManager.php +++ b/src/Entity/BlockManager.php @@ -18,7 +18,7 @@ use Sonata\DashboardBundle\Model\DashboardBlockInterface; use Sonata\DashboardBundle\Model\DashboardInterface; use Sonata\DatagridBundle\Pager\Doctrine\Pager; -use Sonata\DatagridBundle\ProxyQuery\Doctrine\ProxyQuery; +use Sonata\DatagridBundle\Pager\PagerInterface; use Sonata\Doctrine\Entity\BaseEntityManager; /** @@ -74,7 +74,7 @@ public function updatePosition(int $id, int $position, ?int $parentId = null, ?i return $block; } - public function getPager(array $criteria, $page, $limit = 10, array $sort = []) + public function getPager(array $criteria, int $page, int $limit = 10, array $sort = []): PagerInterface { $query = $this->getRepository() ->createQueryBuilder('b') @@ -94,12 +94,6 @@ public function getPager(array $criteria, $page, $limit = 10, array $sort = []) $query->setParameters($parameters); - $pager = new Pager(); - $pager->setMaxPerPage($limit); - $pager->setQuery(new ProxyQuery($query)); - $pager->setPage($page); - $pager->init(); - - return $pager; + return Pager::create($query, $limit, $page); } } diff --git a/src/Entity/DashboardManager.php b/src/Entity/DashboardManager.php index 66c7cd6..54087a9 100644 --- a/src/Entity/DashboardManager.php +++ b/src/Entity/DashboardManager.php @@ -15,7 +15,7 @@ use Sonata\DashboardBundle\Model\DashboardManagerInterface; use Sonata\DatagridBundle\Pager\Doctrine\Pager; -use Sonata\DatagridBundle\ProxyQuery\Doctrine\ProxyQuery; +use Sonata\DatagridBundle\Pager\PagerInterface; use Sonata\Doctrine\Entity\BaseEntityManager; /** @@ -25,7 +25,7 @@ */ final class DashboardManager extends BaseEntityManager implements DashboardManagerInterface { - public function getPager(array $criteria, $page, $limit = 10, array $sort = []) + public function getPager(array $criteria, int $page, int $limit = 10, array $sort = []): PagerInterface { $query = $this->getRepository() ->createQueryBuilder('d') @@ -54,12 +54,6 @@ public function getPager(array $criteria, $page, $limit = 10, array $sort = []) $query->setParameters($parameters); - $pager = new Pager(); - $pager->setMaxPerPage($limit); - $pager->setQuery(new ProxyQuery($query)); - $pager->setPage($page); - $pager->init(); - - return $pager; + return Pager::create($query, $limit, $page); } } diff --git a/src/Model/BlockManagerInterface.php b/src/Model/BlockManagerInterface.php index c407a47..8e64f22 100644 --- a/src/Model/BlockManagerInterface.php +++ b/src/Model/BlockManagerInterface.php @@ -14,10 +14,14 @@ namespace Sonata\DashboardBundle\Model; use Sonata\BlockBundle\Model\BlockInterface; +use Sonata\DatagridBundle\Pager\PageableInterface; use Sonata\Doctrine\Model\ManagerInterface; -use Sonata\Doctrine\Model\PageableManagerInterface; -interface BlockManagerInterface extends ManagerInterface, PageableManagerInterface +/** + * @phpstan-implements ManagerInterface + * @phpstan-implements PageableInterface + */ +interface BlockManagerInterface extends ManagerInterface, PageableInterface { /** * Updates position for given block. diff --git a/src/Model/DashboardManagerInterface.php b/src/Model/DashboardManagerInterface.php index 4bec9ed..707387b 100644 --- a/src/Model/DashboardManagerInterface.php +++ b/src/Model/DashboardManagerInterface.php @@ -13,14 +13,17 @@ namespace Sonata\DashboardBundle\Model; +use Sonata\DatagridBundle\Pager\PageableInterface; use Sonata\Doctrine\Model\ManagerInterface; -use Sonata\Doctrine\Model\PageableManagerInterface; /** * Defines methods to interact with the persistency layer of a DashboardInterface. * * @author Quentin Somazzi + * + * @phpstan-implements ManagerInterface + * @phpstan-implements PageableInterface */ -interface DashboardManagerInterface extends ManagerInterface, PageableManagerInterface +interface DashboardManagerInterface extends ManagerInterface, PageableInterface { }