File tree Expand file tree Collapse file tree
src/Spryker/ApiPlatform/State/Provider Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -96,12 +96,22 @@ protected function getPaginationOffset(int $offset = self::DEFAULT_OFFSET): int
9696 * Builds a {@see PaginationTransfer} pre-populated with `?page[limit]` and `?page[offset]`
9797 * from the current request. Convenience helper for criteria-style facades/clients that
9898 * accept a `PaginationTransfer` (e.g. `$criteria->setPagination($this->buildPaginationTransfer())`).
99+ *
100+ * Sets all four equivalent representations of the page coordinate — `limit`/`offset` (search-style)
101+ * and `maxPerPage`/`page` (1-based, legacy Zed-reader style) — so the transfer satisfies both
102+ * reader flavours without the caller having to translate. Page is derived as
103+ * `floor(offset / limit) + 1`; the two pairs stay in sync.
99104 */
100105 protected function buildPaginationTransfer (int $ limit = self ::DEFAULT_LIMIT , int $ offset = self ::DEFAULT_OFFSET ): PaginationTransfer
101106 {
107+ $ resolvedLimit = $ this ->getPaginationLimit ($ limit );
108+ $ resolvedOffset = $ this ->getPaginationOffset ($ offset );
109+
102110 return (new PaginationTransfer ())
103- ->setLimit ($ this ->getPaginationLimit ($ limit ))
104- ->setOffset ($ this ->getPaginationOffset ($ offset ));
111+ ->setLimit ($ resolvedLimit )
112+ ->setOffset ($ resolvedOffset )
113+ ->setMaxPerPage ($ resolvedLimit )
114+ ->setPage (intdiv ($ resolvedOffset , max ($ resolvedLimit , 1 )) + 1 );
105115 }
106116
107117 /**
You can’t perform that action at this time.
0 commit comments