Skip to content

Commit 2ce8b64

Browse files
Coussecousseerika
andauthored
Session: Convert sessions page paginator to array
Co-authored-by: erika <eandre-do-brito@linagora.com>
1 parent 611c21a commit 2ce8b64

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/CoreBundle/State/UserSessionSubscriptionsStateProvider.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
namespace Chamilo\CoreBundle\State;
88

99
use ApiPlatform\Doctrine\Orm\Extension\PaginationExtension;
10+
use ApiPlatform\Doctrine\Orm\Paginator;
1011
use ApiPlatform\Doctrine\Orm\Util\QueryNameGenerator;
1112
use ApiPlatform\Metadata\Operation;
1213
use ApiPlatform\State\ProviderInterface;
@@ -75,6 +76,20 @@ public function provide(Operation $operation, array $uriVariables = [], array $c
7576
$context
7677
);
7778

78-
return $this->paginationExtension->getResult($qb, Session::class, $operation, $context);
79+
$paginator = $this->paginationExtension->getResult($qb, Session::class, $operation, $context);
80+
81+
// Convert paginator to array since paginationEnabled is false
82+
$result = $paginator;
83+
84+
if ($result instanceof Paginator) {
85+
return iterator_to_array($result);
86+
}
87+
88+
// If it's already an array or collection, convert to array
89+
if (is_iterable($result)) {
90+
return \is_array($result) ? $result : iterator_to_array($result);
91+
}
92+
93+
return [];
7994
}
8095
}

0 commit comments

Comments
 (0)