How to use Paginator after Upgrading to 4.4.0

Hi
At migration guide ( 4.4 Migration Guide - 4.x ) it mention

* The `paginator` option for `Controller::paginate()` is deprecated. Instead use the `className` option.

* The `paginator` option for `PaginatorComponent` is deprecated. Instead use the `className` option.

but at Pagination - 4.x page, It does not mention about how to use className option ?

Right now if debug mode is true then i got this error

[**Deprecated** (16384) ](javascript:void(0);): PaginatorComponent is deprecated, use a Cake\Datasource\Pagination\NumericPaginator instance directly.

It works if debug mode is false but Where i can find code for pagination in cakephp 4.4

Thanks

Hi @yogeshsaroya,

Not sure what your code looks like but found I had to remove/change the following

$this->loadComponent('Paginator'); // remove this line from all your code
// 
$this->paginate($whatYouArePaginating, [
         'paginator' => 'YourPaginatorClass', // remove this if it exists 
         'className' => 'YourPaginatorClass' // add this
]);

// or if assigning to  the property
$this->paginate =  [
         'paginator' => 'YourPaginatorClass', // remove this if it exists 
         'className' => 'YourPaginatorClass' // add this
];

// or

public $paginate =  [
         'paginator' => 'YourPaginatorClass', // remove this if it exists 
         'className' => 'YourPaginatorClass' // add this or just don't specify to use default NumericPaginator class.
];
1 Like