Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
Merge pull request #176 from whiteoctober/fix/158-first-page
Browse files Browse the repository at this point in the history
Fix: 'Problem with "omitFirstPage: true" - can't navigate to first page.'
  • Loading branch information
Sam Partington authored Nov 30, 2017
2 parents 5fd47a5 + a252e1d commit 9b1f3d4
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Twig/PagerfantaExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,9 @@ private function createRouteGenerator($options = array())

return function($page) use($router, $routeName, $routeParams, $pagePropertyPath, $omitFirstPage) {
$propertyAccessor = PropertyAccess::createPropertyAccessor();
// don't set the page parameter if it is the first page and the omitFirstPage flag is true
if(!$omitFirstPage || $page > 1 ){
if($omitFirstPage){
$propertyAccessor->setValue($routeParams, $pagePropertyPath, $page > 1 ? $page : null);
} else {
$propertyAccessor->setValue($routeParams, $pagePropertyPath, $page);
}

Expand Down

0 comments on commit 9b1f3d4

Please sign in to comment.