PaginatorComponent can use Cake\ORM\Query
as an object for pagination, so I would suggest passing your compiled request object to paginator.
, - .
public function example()
{
$this->paginate = ['limit' => 5];
$query = $this->Examples->find();
if ($something === 'foo') {
$query->where(['foo' => $something]);
}
if ($wtfbbq) {
$query->contain(['Wtfs', 'Barbeques']);
}
$results = $this->paginate($query);
}
Cake\ORM\Query
. , , Paginator.