public function getPaginator($params) 
	{
        $limit = isset($params['limit']) ? (int) $params['limit'] : 10;
        $offset = isset($params['offset']) ? (int) $params['offset'] : 0;
        
        // @todo (re)setting limit and offset, make it better...
        $params['limit'] = $limit;
        $params['offset'] = $offset;
		
		// must check for limit
		//$page = isset($params['page']) ? (int)$params['page'] : 1;
		
		$fields = isset($params['field']) ? array_values($params['field']) : array();
		$values = isset($params['value']) ? array_values($params['value']) : array();
		
		$page = $params['offset'] / $params['limit'] + 1;
		$isLoggedUserSearch = false;
		$isFullSearch = false;
		$userId = '';
		foreach($fields as $key => $field) {
			switch($field) {
				case 'account':
					$isLoggedUserSearch = true;
					$userId = $values[$key];
					break;
			}
		}
		if($isLoggedUserSearch) {
			    //throw new \Exception('WIP hashid');
			$qb = $this->_em->createQueryBuilder();
			$qb->select(array('a'));
			$qb->from($this->getEntityName(), 'a');
			//$qb->andWhere($qb->expr()->eq('a.user', ':paramUserId'));
			$qb->andWhere($qb->expr()->eq('SHA1(CONCAT_WS(\'\', \'neo\', a.user, \'bazaar\'))', ':paramUserId'));
			$qb->andWhere($qb->expr()->eq('a.documentType', ':paramDocumentType'));
			$qb->andWhere($qb->expr()->neq('a.state', ':paramDocumentState'));
			$qb->setParameter('paramUserId', $userId);
			$qb->setParameter('paramDocumentType', Document::DOCUMENT_TYPE_CLASSIFIED);
			$qb->setParameter('paramDocumentState', Document::DOCUMENT_STATE_DELETED);
			//$qb->addOrderBy('COALESCE(a.dateEdit, a.dateInsert)', 'DESC');
			//$qb->addOrderBy('a.documentId', 'DESC');
			$qb->addOrderBy('a.dateEdit', 'DESC');
			$query = $qb->getQuery();
			$query->setFirstResult($params['offset']);
			$query->setMaxResults($params['limit']);
			$paginatorAdapter = new DoctrinePaginatorAdapter(new DoctrinePaginator($query));
			
			
// 			$paginator = new DoctrinePaginator($query, $fetchJoinCollection = true);
// 			$result = array();
// 			foreach($paginator as $p) {
// 				$result[] = $p->getDocumentId();
// 			}
// 			$result = $query->getResult();
// 			$paginatorAdapter =  new RazorPaginator(
// 				$result,
// 				count($paginator)
// 			);
		} else {
			$query = $this->fetchGridData($params);
			$query->setFirstResult(0);
			$query->setMaxResults($params['limit']);
			$paginatorAdapter =  new RazorArrayAdapter(
				$query->getResult(),
				$this->getSphinxClient()->getLastSearchCount()
			);
			//$paginatorAdapter = new DoctrinePaginatorAdapter(new DoctrinePaginator($query));
		}
		
		
		$paginator = new Paginator($paginatorAdapter);
		$paginator->setCurrentPageNumber($page);
		$paginator->setDefaultItemCountPerPage($params['limit']);
		
		return $paginator;
	}
public function getPaginator($params) 
	{
        $limit = isset($params['limit']) ? (int) $params['limit'] : 10;
        $offset = isset($params['offset']) ? (int) $params['offset'] : 0;
        
        // @todo (re)setting limit and offset, make it better...
        $params['limit'] = $limit;
        $params['offset'] = $offset;
		
		// must check for limit
		//$page = isset($params['page']) ? (int)$params['page'] : 1;
		
		$fields = isset($params['field']) ? array_values($params['field']) : array();
		$values = isset($params['value']) ? array_values($params['value']) : array();
		
		$page = $params['offset'] / $params['limit'] + 1;
		$isLoggedUserSearch = false;
		$isFullSearch = false;
		$userId = '';
		foreach($fields as $key => $field) {
			switch($field) {
				case 'account':
					$isLoggedUserSearch = true;
					$userId = $values[$key];
					break;
			}
		}
		if($isLoggedUserSearch) {
			    //throw new \Exception('WIP hashid');
			$qb = $this->_em->createQueryBuilder();
			$qb->select(array('a'));
			$qb->from($this->getEntityName(), 'a');
			//$qb->andWhere($qb->expr()->eq('a.user', ':paramUserId'));
			$qb->andWhere($qb->expr()->eq('SHA1(CONCAT_WS(\'\', \'neo\', a.user, \'bazaar\'))', ':paramUserId'));
			$qb->andWhere($qb->expr()->eq('a.documentType', ':paramDocumentType'));
			$qb->andWhere($qb->expr()->neq('a.state', ':paramDocumentState'));
			$qb->setParameter('paramUserId', $userId);
			$qb->setParameter('paramDocumentType', Document::DOCUMENT_TYPE_CLASSIFIED);
			$qb->setParameter('paramDocumentState', Document::DOCUMENT_STATE_DELETED);
			//$qb->addOrderBy('COALESCE(a.dateEdit, a.dateInsert)', 'DESC');
			//$qb->addOrderBy('a.documentId', 'DESC');
			$qb->addOrderBy('a.dateEdit', 'DESC');
			$query = $qb->getQuery();
			$query->setFirstResult($params['offset']);
			$query->setMaxResults($params['limit']);
			$paginatorAdapter = new DoctrinePaginatorAdapter(new DoctrinePaginator($query));
			
			
// 			$paginator = new DoctrinePaginator($query, $fetchJoinCollection = true);
// 			$result = array();
// 			foreach($paginator as $p) {
// 				$result[] = $p->getDocumentId();
// 			}
// 			$result = $query->getResult();
// 			$paginatorAdapter =  new RazorPaginator(
// 				$result,
// 				count($paginator)
// 			);
		} else {
			$query = $this->fetchGridData($params);
			$query->setFirstResult(0);
			$query->setMaxResults($params['limit']);
			$paginatorAdapter =  new RazorArrayAdapter(
				$query->getResult(),
				$this->getSphinxClient()->getLastSearchCount()
			);
			//$paginatorAdapter = new DoctrinePaginatorAdapter(new DoctrinePaginator($query));
		}
		
		
		$paginator = new Paginator($paginatorAdapter);
		$paginator->setCurrentPageNumber($page);
		$paginator->setDefaultItemCountPerPage($params['limit']);
		
		return $paginator;
	}
public function getPaginator ( $ params ) { $ limit = isset ( $ params [ 'limit' ] ) ? ( int ) $ params [ 'limit' ] : 10 ; $ offset = isset ( $ params [ 'offset' ] ) ? ( int ) $ params [ 'offset' ] : 0 ; // @todo (re)setting limit and offset, make it better... $ params [ 'limit' ] = $ limit ; $ params [ 'offset' ] = $ offset ; // must check for limit //$page = isset($params['page']) ? (int)$params['page'] : 1; $ fields = isset ( $ params [ 'field' ] ) ? array_values ( $ params [ 'field' ] ) : array ( ) ; $ values = isset ( $ params [ 'value' ] ) ? array_values ( $ params [ 'value' ] ) : array ( ) ; $ page = $ params [ 'offset' ] / $ params [ 'limit' ] + 1 ; $ isLoggedUserSearch = false ; $ isFullSearch = false ; $ userId = '' ; foreach ( $ fields as $ key => $ field ) { switch ( $ field ) { case 'account' : $ isLoggedUserSearch = true ; $ userId = $ values [ $ key ] ; break ; } } if ( $ isLoggedUserSearch ) { //throw new \Exception('WIP hashid'); $ qb = $ this -> _em -> createQueryBuilder ( ) ; $ qb -> select ( array ( 'a' ) ) ; $ qb -> from ( $ this -> getEntityName ( ) , 'a' ) ; //$qb->andWhere($qb->expr()->eq('a.user', ':paramUserId')); $ qb -> andWhere ( $ qb -> expr ( ) -> eq ( 'SHA1(CONCAT_WS(\'\', \'neo\', a.user, \'bazaar\'))' , ':paramUserId' ) ) ; $ qb -> andWhere ( $ qb -> expr ( ) -> eq ( 'a.documentType' , ':paramDocumentType' ) ) ; $ qb -> andWhere ( $ qb -> expr ( ) -> neq ( 'a.state' , ':paramDocumentState' ) ) ; $ qb -> setParameter ( 'paramUserId' , $ userId ) ; $ qb -> setParameter ( 'paramDocumentType' , Document :: DOCUMENT_TYPE_CLASSIFIED ) ; $ qb -> setParameter ( 'paramDocumentState' , Document :: DOCUMENT_STATE_DELETED ) ; //$qb->addOrderBy('COALESCE(a.dateEdit, a.dateInsert)', 'DESC'); //$qb->addOrderBy('a.documentId', 'DESC'); $ qb -> addOrderBy ( 'a.dateEdit' , 'DESC' ) ; $ query = $ qb -> getQuery ( ) ; $ query -> setFirstResult ( $ params [ 'offset' ] ) ; $ query -> setMaxResults ( $ params [ 'limit' ] ) ; $ paginatorAdapter = new DoctrinePaginatorAdapter ( new DoctrinePaginator ( $ query ) ) ; // 			$paginator = new DoctrinePaginator($query, $fetchJoinCollection = true); // 			$result = array(); // 			foreach($paginator as $p) { // 				$result[] = $p->getDocumentId(); // 			} // 			$result = $query->getResult(); // 			$paginatorAdapter =  new RazorPaginator( // 				$result, // 				count($paginator) // 			); } else { $ query = $ this -> fetchGridData ( $ params ) ; $ query -> setFirstResult ( 0 ) ; $ query -> setMaxResults ( $ params [ 'limit' ] ) ; $ paginatorAdapter = new RazorArrayAdapter ( $ query -> getResult ( ) , $ this -> getSphinxClient ( ) -> getLastSearchCount ( ) ) ; //$paginatorAdapter = new DoctrinePaginatorAdapter(new DoctrinePaginator($query)); } $ paginator = new Paginator ( $ paginatorAdapter ) ; $ paginator -> setCurrentPageNumber ( $ page ) ; $ paginator -> setDefaultItemCountPerPage ( $ params [ 'limit' ] ) ; return $ paginator ; }
Create paginator Object

@return Zend\Paginator\Paginator
Create paginator Object