Skip to content

Commit

Permalink
Make it possible to paginate queries other than ORM/Query
Browse files Browse the repository at this point in the history
  • Loading branch information
Marlinc committed Oct 9, 2015
1 parent c2aae82 commit 22f960b
Show file tree
Hide file tree
Showing 4 changed files with 439 additions and 77 deletions.
7 changes: 3 additions & 4 deletions src/Controller/Component/PaginatorComponent.php
Expand Up @@ -15,10 +15,9 @@
namespace Cake\Controller\Component;

use Cake\Controller\Component;
use Cake\Datasource\QueryInterface;
use Cake\Datasource\RepositoryInterface;
use Cake\Network\Exception\NotFoundException;
use Cake\ORM\Query;
use Cake\ORM\Table;

/**
* This component is used to handle automatic model data pagination. The primary way to use this
Expand Down Expand Up @@ -142,14 +141,14 @@ public function implementedEvents()
* $results = $paginator->paginate($query);
* ```
*
* @param \Cake\Datasource\RepositoryInterface|\Cake\ORM\Query $object The table or query to paginate.
* @param \Cake\Datasource\RepositoryInterface|\Cake\Datasource\QueryInterface $object The table or query to paginate.
* @param array $settings The settings/configuration used for pagination.
* @return array Query results
* @throws \Cake\Network\Exception\NotFoundException
*/
public function paginate($object, array $settings = [])
{
if ($object instanceof Query) {
if ($object instanceof QueryInterface) {
$query = $object;
$object = $query->repository();
}
Expand Down

0 comments on commit 22f960b

Please sign in to comment.