/**
  * @param array $criteria
  * @param integer $page
  *
  * @return \Sonata\AdminBundle\Datagrid\ODM\Pager
  */
 public function getPager(array $criteria, $page)
 {
     $parameters = array();
     $qb = $this->dm->getRepository($this->class)->createQueryBuilder()->sort('createdAt', 'desc');
     $criteria['status'] = isset($criteria['status']) ? $criteria['status'] : CommentInterface::STATUS_VALID;
     $qb->field('status')->equals($criteria['status']);
     if (isset($criteria['postId'])) {
         $qb->field('post')->equals($criteria['postId']);
     }
     $pager = new Pager(500);
     // no limit
     $pager->setQuery(new ProxyQuery($qb));
     $pager->setPage($page);
     $pager->init();
     return $pager;
 }
 /**
  * {@inheritdoc}
  */
 public function getPager(array $criteria, $page, $limit = 10, array $sort = array())
 {
     $parameters = array();
     $query = $this->getRepository()->createQueryBuilder('p')->select('p, t')->leftJoin('p.tags', 't')->orderby('p.publicationDateStart', 'DESC');
     // enabled
     $criteria['enabled'] = isset($criteria['enabled']) ? $criteria['enabled'] : true;
     $query->andWhere('p.enabled = :enabled');
     $parameters['enabled'] = $criteria['enabled'];
     if (isset($criteria['date'])) {
         $query->andWhere($criteria['date']['query']);
         $parameters = array_merge($parameters, $criteria['date']['params']);
     }
     if (isset($criteria['tag'])) {
         $query->andWhere('t.slug LIKE :tag and t.enabled = :tag_enabled');
         $parameters['tag'] = $criteria['tag'];
         $parameters['tag_enabled'] = true;
     }
     $query->setParameters($parameters);
     $pager = new Pager();
     $pager->setQuery(new ProxyQuery($query));
     $pager->setPage($page);
     $pager->init();
     return $pager;
 }