Skip to content

Commit

Permalink
Add support for pagerfanta 3
Browse files Browse the repository at this point in the history
  • Loading branch information
loic425 committed Jan 25, 2022
1 parent d462d9f commit c54718a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
8 changes: 5 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@
"lchrusciel/api-test-case": "^5.0",
"matthiasnoback/symfony-config-test": "^4.2.1",
"matthiasnoback/symfony-dependency-injection-test": "^4.2.1",
"pagerfanta/pagerfanta": "^1.1 || ^2.5",
"pagerfanta/pagerfanta": "^3.0",
"pamil/phpspec-skip-example-extension": "^4.2",
"phpspec/phpspec": "^7.0",
"phpstan/phpstan": "0.12.99",
"phpstan/phpstan-phpunit": "0.12.22",
"phpstan/phpstan-webmozart-assert": "0.12.16",
"phpunit/phpunit": "^9.5",
"sylius-labs/coding-standard": "^4.0",
"sylius/resource-bundle": "^1.8",
"sylius/resource-bundle": "^1.9",
"symfony/console": "^4.4 || ^5.4",
"symfony/dotenv": "^4.4 || ^5.4",
"symfony/polyfill-mbstring": "<1.22.0 || >1.22.0",
Expand Down Expand Up @@ -120,5 +120,7 @@
"test-with-postgres": [
"APP_ENV=test_with_postgres vendor/bin/phpunit --colors=always"
]
}
},
"minimum-stability": "dev",
"prefer-stable": true
}
4 changes: 2 additions & 2 deletions src/Bundle/Doctrine/DBAL/DataSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
namespace Sylius\Bundle\GridBundle\Doctrine\DBAL;

use Doctrine\DBAL\Query\QueryBuilder;
use Pagerfanta\Adapter\DoctrineDbalAdapter;
use Pagerfanta\Doctrine\DBAL\QueryAdapter;;
use Pagerfanta\Pagerfanta;
use Sylius\Component\Grid\Data\DataSourceInterface;
use Sylius\Component\Grid\Data\ExpressionBuilderInterface;
Expand Down Expand Up @@ -60,7 +60,7 @@ public function getData(Parameters $parameters)
;
};

$paginator = new Pagerfanta(new DoctrineDbalAdapter($this->queryBuilder, $countQueryBuilderModifier));
$paginator = new Pagerfanta(new QueryAdapter($this->queryBuilder, $countQueryBuilderModifier));
$paginator->setNormalizeOutOfRangePages(true);
$paginator->setCurrentPage($parameters->get('page', 1));

Expand Down
4 changes: 2 additions & 2 deletions src/Bundle/Doctrine/ORM/DataSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
namespace Sylius\Bundle\GridBundle\Doctrine\ORM;

use Doctrine\ORM\QueryBuilder;
use Pagerfanta\Adapter\DoctrineORMAdapter;
use Pagerfanta\Doctrine\ORM\QueryAdapter;
use Pagerfanta\Pagerfanta;
use Sylius\Component\Grid\Data\DataSourceInterface;
use Sylius\Component\Grid\Data\ExpressionBuilderInterface;
Expand Down Expand Up @@ -68,7 +68,7 @@ public function getExpressionBuilder(): ExpressionBuilderInterface
public function getData(Parameters $parameters)
{
$paginator = new Pagerfanta(
new DoctrineORMAdapter($this->queryBuilder, $this->fetchJoinCollection, $this->useOutputWalkers)
new QueryAdapter($this->queryBuilder, $this->fetchJoinCollection, $this->useOutputWalkers)
);
$paginator->setNormalizeOutOfRangePages(true);
$paginator->setCurrentPage($parameters->get('page', 1));
Expand Down
4 changes: 2 additions & 2 deletions src/Bundle/Doctrine/PHPCRODM/DataSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
namespace Sylius\Bundle\GridBundle\Doctrine\PHPCRODM;

use Doctrine\ODM\PHPCR\Query\Builder\QueryBuilder;
use Pagerfanta\Adapter\DoctrineODMPhpcrAdapter;
use Pagerfanta\Doctrine\PHPCRODM\QueryAdapter;
use Pagerfanta\Pagerfanta;
use Sylius\Component\Grid\Data\DataSourceInterface;
use Sylius\Component\Grid\Data\ExpressionBuilderInterface;
Expand Down Expand Up @@ -75,7 +75,7 @@ public function getData(Parameters $parameters)
$orderBy->{$direction}()->field(sprintf('%s.%s', Driver::QB_SOURCE_ALIAS, $field));
}

$paginator = new Pagerfanta(new DoctrineODMPhpcrAdapter($this->queryBuilder));
$paginator = new Pagerfanta(new QueryAdapter($this->queryBuilder));
$paginator->setCurrentPage($parameters->get('page', 1));

return $paginator;
Expand Down

0 comments on commit c54718a

Please sign in to comment.