Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Moln committed Feb 20, 2021
1 parent 8a3c077 commit e4479cc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/Basic/CollectionNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,17 @@ protected function getPaginationData($object, array $context = []): array
{
[$currentPage, $itemsPerPage, $totalItems, $pageCount] = $this->getPaginationConfig($object, $context);

if ($totalItems) {
$data = [];
if ($totalItems !== null) {
$data['total'] = $totalItems;
}
if ($currentPage) {
if ($currentPage !== null) {
$data['page'] = $currentPage;
}
if ($pageCount) {
if ($pageCount !== null) {
$data['page_count'] = $pageCount;
}
if ($itemsPerPage) {
if ($itemsPerPage !== null) {
$data['page_size'] = $itemsPerPage;
}

Expand Down
1 change: 1 addition & 0 deletions src/Serializer/AbstractCollectionNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public function supportsNormalization($data, $format = null, array $context = []
return static::FORMAT === $format &&
is_iterable($data) &&
isset($context['api_resource']) &&
$context['api_resource'] == 'collection' &&
!isset($context['api_sub_level']);
}

Expand Down

0 comments on commit e4479cc

Please sign in to comment.