Pass data to pagintion helper? CakePHP 3.6


#1

I have custom rest source, and in cakephp 3.5.* while testings, I use “little hack” to pass params to paginatoin helper, like:

    $this->request->params['paging']['Posts'] = [
        'finder' => 'all',
        'page' => $page,
        'current' => $solr['rows'] * $page,
        'count' => $json['response']['numFound'],
        'perPage' => $solr['rows'],
        'prevPage' => $page > 1 ? true : false,
        'nextPage' => $page < $pageCount ? true : false,
        'pageCount' => $pageCount,
        'sort' => null,
        'direction' => false,
        'limit' => null,
        'sortDefault' => false,
        'directionDefault' => false,
        'scope' => null
    ];

But after upgrade to 3.6 this no more work when try to fix depractited code.

Accessing "params" as a property will be removed in 4.0.0. Use request->getParam() instead.

Any idea?


#2

Hello,

Probably not the best way to do it, but a working one, I am using “action scoped” session.

I store the params sent in the session in a array like this one :

[
    'custFilters' => [
        'action1' => [
            'action1_param1' = 'value1',
            'action1_param2' = 'value2'
        ],
        'action2' => [
            'action2_param1' = 'value3',
            'action2_param2' = 'value4'
        ]
    ]
];

Etc.

The behavior is that when you go back to the page, de filters are peristent.

Hope it can help you.

Regards