示例#1
0
 /**
  *
  * @param integer $totalRows
  * @param integer $limit
  * @param integer $offset
  * @throws Exception\InvalidUsageException
  */
 public function __construct($totalRows, $limit, $offset = 0)
 {
     $totalRows = filter_var($totalRows, FILTER_VALIDATE_INT);
     $limit = filter_var($limit, FILTER_VALIDATE_INT);
     $offset = filter_var($offset, FILTER_VALIDATE_INT);
     if (!is_int($limit) || $limit < 0) {
         throw new Exception\InvalidUsageException(__METHOD__ . ' expects limit to be an integer greater than 0');
     }
     if (!is_int($totalRows) || $totalRows < 0) {
         throw new Exception\InvalidUsageException(__METHOD__ . ' expects total rows to be an integer greater than 0');
     }
     if (!is_int($offset) || $offset < 0) {
         throw new Exception\InvalidUsageException(__METHOD__ . ' expects offset to be an integer greater than 0');
     }
     if (class_exists('\\Zend\\Paginator\\Adapter\\NullFill')) {
         // In ZF 2.4+
         $adapter = new \Zend\Paginator\Adapter\NullFill($totalRows);
     } elseif (class_exists('\\Zend\\Paginator\\Adapter\\Null')) {
         // In ZF < 2.4
         $adapter = new \Zend\Paginator\Adapter\Null($totalRows);
     } else {
         throw new Exception\RuntimeException(__METHOD__ . " Missing Zend\\Paginator\\Adapter.");
     }
     parent::__construct($adapter);
     $this->setItemCountPerPage($limit);
     $this->setCurrentPageNumber(ceil(($offset + 1) / $limit));
 }
示例#2
0
 function __construct($select, $adapter, $result, $current_page)
 {
     $this->select = $select;
     $this->adapter = $adapter;
     $this->result = new \Zend\Db\ResultSet\ResultSet();
     $this->current_page = $current_page;
     $this->paginatorAdapter = new DbSelect($this->select, $this->adapter, $this->result);
     parent::__construct($this->paginatorAdapter);
     $this->initPaging();
 }
示例#3
0
 public function __construct($paged_object, $page = 1, $limit = 10)
 {
     if ($paged_object instanceof \Doctrine\ORM\Query || $paged_object instanceof \Doctrine\ORM\QueryBuilder) {
         parent::__construct(new Paginator\Adapter\DoctrineQuery($paged_object));
     } elseif (is_array($paged_object)) {
         parent::__construct(new \Zend\Paginator\Adapter\ArrayAdapter($paged_object));
     } else {
         parent::__construct(new \Zend\Paginator\Adapter\NullFill($paged_object));
     }
     $this->setItemCountPerPage($limit);
     $this->setCurrentPageNumber($page);
 }
示例#4
0
 public function __construct(AdapterInterface $adapter)
 {
     $this->proxy = $adapter;
     parent::__construct(new Callback([$this, 'onGetItems'], [$this, 'onCount']));
 }
示例#5
0
 public function __construct(Contact $contactTaskService)
 {
     $this->contactTaskService = $contactTaskService;
     $this->paginator = $this->contactTaskService->getOverviewPaginator('company');
     parent::__construct(new Callback([$this, 'onGetItems'], [$this, 'onCount']));
 }
 public function __construct($userCollection)
 {
     parent::__construct(new ArrayAdapter($userCollection));
 }