Permalink
Browse files

changed DoctrinePaginator to use cursors instead of query builders

  • Loading branch information...
1 parent 3adba20 commit e0dc67fc076fff46d947a5547fe2d2e1e8712ba3 @romankonz romankonz committed Mar 5, 2013
Showing with 12 additions and 12 deletions.
  1. +12 −12 src/DoctrineMongoODMModule/Paginator/Adapter/DoctrinePaginator.php
View
24 src/DoctrineMongoODMModule/Paginator/Adapter/DoctrinePaginator.php
@@ -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,38 +30,38 @@
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;
}
/**
* {@inheritDoc}
*/
public function count()
{
- $query = clone $this->queryBuilder;
- return $query->count()->getQuery()->execute();
+ $cursor = clone $this->cursor;
+ return $cursor->count();
}
/**
* {@inheritDoc}
*/
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;
}
}

0 comments on commit e0dc67f

Please sign in to comment.