-
-
Notifications
You must be signed in to change notification settings - Fork 933
Add traversable paginator #3783
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add traversable paginator #3783
Conversation
14142e9
to
0725643
Compare
Not sure what to do about the failed build checks. The skipped tests that seems be be causing a failure are unrelated to my change, and now I'm seeing a |
we fixed our tests feel free to rebase to relaunch the CI |
4b72c29
to
e0f4ed6
Compare
@soyuka I've rebased & the build is still failing on SwaggerUiAction for both phpcs & phpunit checks. I can take a look at these in a fresh PR if you like? There also looks to be a Github authentication issue? |
Yes there's an issue with github authentification using composer 2 I haven't got the time to dig into that more :/ |
I know that feeling. If I can find a little time I'll see if I can help out. Would you be OK to add the |
Thank you @soyuka . Looks like it needs to be added by a maintainer though, on reading the rules 😏 |
|
||
use Traversable; | ||
|
||
class TraversablePaginator implements \IteratorAggregate, PaginatorInterface |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
class TraversablePaginator implements \IteratorAggregate, PaginatorInterface | |
final class TraversablePaginator implements \IteratorAggregate, PaginatorInterface |
CHANGELOG.md
Outdated
* IriConverter: Fix IRI url double encoding - may cause breaking change as some characters no longer encoded in output (#3552) | ||
* OpenAPI: **BC** Replace all characters other than `[a-zA-Z0-9\.\-_]` to `.` in definition names to be compliant with OpenAPI 3.0 (#3669) | ||
* Add stateless ApiResource attribute | ||
* Add TraversablePaginator |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add it to a new 2.7.0
section please? We'll merge this new feature in the next version.
public function getLastPage(): float | ||
{ | ||
if (0. === $this->itemsPerPage) { | ||
return 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return 1; | |
return 1.; |
private $itemsPerPage; | ||
private $totalItems; | ||
|
||
public function __construct(Traversable $iterator, float $currentPage, float $itemsPerPage, float $totalItems) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public function __construct(Traversable $iterator, float $currentPage, float $itemsPerPage, float $totalItems) | |
public function __construct(\Traversable $iterator, float $currentPage, float $itemsPerPage, float $totalItems) |
|
||
namespace ApiPlatform\Core\DataProvider; | ||
|
||
use Traversable; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use Traversable; |
e0f4ed6
to
87fee54
Compare
Thank you @toby-griffiths! |
I've had need of a paginator for my custom data provider that returns a Generator, so I thought I'd submit this as an addition to the core, if that's so desired?