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

Commit

Permalink
improve omitFirstPage
Browse files Browse the repository at this point in the history
instead of setting the page parameter to null don't set it at all if omitFirstPage is set to true and page is first page. Otherwise some routers may append a questionmark at the end of the url even if there are no other parameters
  • Loading branch information
phibo23 committed Jan 10, 2017
1 parent 63a0a38 commit dfe64b7
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions Twig/PagerfantaExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,8 @@ private function createRouteGenerator($options = array())

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

Expand Down

0 comments on commit dfe64b7

Please sign in to comment.