Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

changed DoctrinePaginator to use cursors instead of query builders

  • Loading branch information...
commit e0dc67fc076fff46d947a5547fe2d2e1e8712ba3 1 parent 3adba20
Roman Konz romankonz authored
Showing with 12 additions and 12 deletions.
  1. +12 −12 src/DoctrineMongoODMModule/Paginator/Adapter/DoctrinePaginator.php
24 src/DoctrineMongoODMModule/Paginator/Adapter/DoctrinePaginator.php
View
@@ -20,7 +20,7 @@
namespace DoctrineMongoODMModule\Paginator\Adapter;
use Zend\Paginator\Adapter\AdapterInterface;
-use \Doctrine\MongoDB\Query\Builder;
+use Doctrine\ODM\MongoDB\Cursor;
/**
* @license MIT
@@ -30,18 +30,18 @@
class DoctrinePaginator implements AdapterInterface
{
/**
- * @var QueryBuilder
+ * @var Doctrine\ODM\MongoDB\Cursor
*/
- protected $queryBuilder;
+ protected $cursor;
/**
* Constructor
*
- * @param \Doctrine\MongoDB\Query\Builder $queryBuilder
+ * @param Doctrine\ODM\MongoDB\Cursor $cursor
*/
- function __construct(Builder $queryBuilder)
+ function __construct(Cursor $cursor)
{
- $this->queryBuilder = $queryBuilder;
+ $this->cursor = $cursor;
}
/**
@@ -49,8 +49,8 @@ function __construct(Builder $queryBuilder)
*/
public function count()
{
- $query = clone $this->queryBuilder;
- return $query->count()->getQuery()->execute();
+ $cursor = clone $this->cursor;
+ return $cursor->count();
}
/**
@@ -58,10 +58,10 @@ public function count()
*/
public function getItems($offset, $itemCountPerPage)
{
- $query = clone $this->queryBuilder;
- $query->skip($offset);
- $query->limit($itemCountPerPage);
- return iterator_to_array($query->getQuery()->execute());
+ $cursor = clone $this->cursor;
+ $cursor->skip($offset);
+ $cursor->limit($itemCountPerPage);
+ return $cursor;
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.