Skip to content

Latest commit

 

History

History
41 lines (33 loc) · 863 Bytes

parameter_name.md

File metadata and controls

41 lines (33 loc) · 863 Bytes

Request parameter name

As default used page as request parameter name. So for first page will be generated / link, for second /?page=2, for third /?page=3 and etc. You can change this parameter name.

Configuration

gpslab_pagination:
    parameter_name: 'p'

Controller

$pagination = new Configuration();
$pagination->setFirstPageLink('/');
$pagination->setPageLink('/?p=%d');
// or you can use callback function
//$pagination->setPageLink(static function (int $number): string {
//    return sprintf('/?p=%d', $number);
//});

Annotations

use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;

/**
 * @ParamConverter("pagination", options={"parameter_name": "p"})
 */
public function index(Configuration $pagination): Response
{
    // ...
}