Skip to content

Commit 8cd8a15

Browse files
committed
Doctrine ORM Paginator should provide possibility to get the Query object
1 parent dab3c78 commit 8cd8a15

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

src/Bridge/Doctrine/Orm/Paginator.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,14 @@
1414
namespace ApiPlatform\Core\Bridge\Doctrine\Orm;
1515

1616
use ApiPlatform\Core\DataProvider\PaginatorInterface;
17+
use Doctrine\ORM\Query;
1718

1819
/**
1920
* Decorates the Doctrine ORM paginator.
2021
*
2122
* @author Kévin Dunglas <[email protected]>
2223
*/
23-
final class Paginator extends AbstractPaginator implements PaginatorInterface
24+
final class Paginator extends AbstractPaginator implements PaginatorInterface, QueryAwareInterface
2425
{
2526
/**
2627
* @var int
@@ -46,4 +47,12 @@ public function getTotalItems(): float
4647
{
4748
return (float) ($this->totalItems ?? $this->totalItems = \count($this->paginator));
4849
}
50+
51+
/**
52+
* {@inheritdoc}
53+
*/
54+
public function getQuery(): Query
55+
{
56+
return $this->paginator->getQuery();
57+
}
4958
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the API Platform project.
5+
*
6+
* (c) Kévin Dunglas <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
declare(strict_types=1);
13+
14+
namespace ApiPlatform\Core\Bridge\Doctrine\Orm;
15+
16+
use Doctrine\ORM\Query;
17+
18+
interface QueryAwareInterface
19+
{
20+
/**
21+
* Gets the Query object that will actually be executed.
22+
*
23+
* This should allow configuring options which could only be set on the Query
24+
* object itself.
25+
*/
26+
public function getQuery(): Query;
27+
}

0 commit comments

Comments
 (0)