Added pagination to ShortUrls list

This commit is contained in:
Alejandro Celaya
2016-07-04 09:15:50 +02:00
parent 35f1a4b672
commit cc1829f9ed
8 changed files with 109 additions and 9 deletions

View File

@@ -8,6 +8,7 @@ use Acelaya\ZsmAnnotatedServices\Annotation\Inject;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Zend\Diactoros\Response\JsonResponse;
use Zend\Stdlib\ArrayUtils;
use Zend\Stratigility\MiddlewareInterface;
class ListShortcodesMiddleware implements MiddlewareInterface
@@ -60,8 +61,11 @@ class ListShortcodesMiddleware implements MiddlewareInterface
return new JsonResponse([
'shortUrls' => [
'data' => $shortUrls,
// 'pagination' => [],
'data' => ArrayUtils::iteratorToArray($shortUrls->getCurrentItems()),
'pagination' => [
'currentPage' => $shortUrls->getCurrentPageNumber(),
'pagesCount' => $shortUrls->count(),
],
]
]);
} catch (\Exception $e) {