Finding query parameters using paginator knp and FOSElastica

I had a problem with the correct implementation of the paginator ppn collation function for my Symfony2 application. I believe that the reason I am encountering problems is because I do not know how FOSElastica builds requests from its built-in paginator and therefore does not know what parameters are passed in knp_pagination_sortable(...)in my twig file. Here is how I do my paginator in my controller:

$finder = $this->get('fos_elastica.finder.employees.employee');

$paginator = $this->get('knp_paginator');

// $name is a parameter that is properly passed to my action function in
// the controller
$knp =  $paginator->paginate(
            $finder->createPaginatorAdapter($name),
            $this->get('request')->get('page', $page),
            25
        );

This is the part of the twig file where I am trying to implement a sort function:

<table border="1">
       <tr>
            <th>{{ knp_pagination_sortable(my_pager, 'Employee Number', 'emp_no') }}</th>
            <th>{{ knp_pagination_sortable(my_pager, 'First Name', 'first_name') }}</th>
                    <th>{{ knp_pagination_sortable(my_pager, 'Last Name', 'last_name') }}</th>
            <th>{{ knp_pagination_sortable(my_pager, 'Birth Date', 'birth_date') }}</th>
                    <th>{{ knp_pagination_sortable(my_pager, 'Gender', 'gender') }}</th>
                    <th>{{ knp_pagination_sortable(my_pager, 'Hire Date', 'hire_date') }}</th>
       </tr>
       {% for employee in my_pager %}
        <tr>
            <td>{{ employee.empNo }}</td>
            <td>{{ employee.firstName }}</td>
            <td>{{ employee.lastName }}</td>
            <td>{{ employee.birthDate|date('M j Y') }}</td>
            <td>{{ employee.gender }}</td>
            <td>{{ employee.hireDate|date('M j Y') }}</td>
        </tr>
       {% endfor %}
</table>

Assuming $ name is a properly formatted string, does anyone know what the query will look like inside the PaginatorAdapter object? I tried var_dump, but the request is a private parameter and does not have a get method (of course).

+3
source share

All Articles