Skip to content
This repository has been archived by the owner on Jul 22, 2022. It is now read-only.

Commit

Permalink
Bump sonata-project/datagrid-bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
core23 authored and jordisala1991 committed Mar 15, 2021
1 parent 897d085 commit f8047ba
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 23 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
12 changes: 3 additions & 9 deletions src/Entity/BlockManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down Expand Up @@ -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')
Expand All @@ -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);
}
}
12 changes: 3 additions & 9 deletions src/Entity/DashboardManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -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')
Expand Down Expand Up @@ -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);
}
}
8 changes: 6 additions & 2 deletions src/Model/BlockManagerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<BlockInterface>
* @phpstan-implements PageableInterface<BlockInterface>
*/
interface BlockManagerInterface extends ManagerInterface, PageableInterface
{
/**
* Updates position for given block.
Expand Down
7 changes: 5 additions & 2 deletions src/Model/DashboardManagerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>
*
* @phpstan-implements ManagerInterface<BlockInterface>
* @phpstan-implements PageableInterface<BlockInterface>
*/
interface DashboardManagerInterface extends ManagerInterface, PageableManagerInterface
interface DashboardManagerInterface extends ManagerInterface, PageableInterface
{
}

0 comments on commit f8047ba

Please sign in to comment.