The Content Management Tutorial at cakephp throws deprecation errors concerning the paginator.
This code is the source for the warning.
<?php
// src/Controller/ArticlesController.php
namespace AppController;
use AppControllerAppController;
class ArticlesController extends AppController
{
public function initialize(): void
{
parent::initialize();
$this->loadComponent('Paginator');
$this->loadComponent('Flash'); // Include the FlashComponent
}
public function index()
{
$articles = $this->Paginator->paginate($this->Articles->find());
$this->set(compact('articles'));
}
It generates the warning
Deprecated (16384) : PaginatorComponent is deprecated, use a CakeDatasourcePaginationNumericPaginator instance directly. /home/..../vendor/cakephp/cakephp/src/Controller/ComponentRegistry.php, line: 133
Found two hints to change the source. Remove the loadComponent and change the pagination method.
<?php
// src/Controller/ArticlesController.php
namespace AppController;
use AppControllerAppController;
class ArticlesController extends AppController
{
public function initialize(): void
{
parent::initialize();
$this->loadComponent('Flash'); // Include the FlashComponent
}
public function index()
{
// Paginate the ORM table.
$this->set('articles', $this->paginate($this->Articles));
$this->set(compact('articles'));
}
Background for pagination 4.x cakephp doc pagination