cphalcon
cphalcon copied to clipboard
[NFR] Paginator page
$currentPage = $this->request->getQuery('page', 'int', 1);
$paginator = new \Phalcon\Paginator\Adapter\Model(
array(
"data" => $items,
"limit" => 25,
"page" => $currentPage
)
);
If $currentPage < 1 it throws and exception... it's good, but this engenders new 'if' that will check this condition in every controller - this is annoying... this is small... but it would be great if
if ($currentPage < 1) $currentPage = 1;
...check was inside paginator. Thanks.
I think throwing an exception is the correct behavior.
If you don't care about negative values the best solution would be
$currentPage = max(1, $this->request->getQuery('page', 'int', 1));
But I think you should send 404 error in such cases.
This is implemented in 1.1.0