本文整理汇总了PHP中Zend\Paginator\Paginator::__construct方法的典型用法代码示例。如果您正苦于以下问题:PHP Paginator::__construct方法的具体用法?PHP Paginator::__construct怎么用?PHP Paginator::__construct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Paginator\Paginator
的用法示例。
在下文中一共展示了Paginator::__construct方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
*
* @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: DbSelect
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: __construct
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: __construct
public function __construct(AdapterInterface $adapter)
{
$this->proxy = $adapter;
parent::__construct(new Callback([$this, 'onGetItems'], [$this, 'onCount']));
}
示例5: __construct
public function __construct(Contact $contactTaskService)
{
$this->contactTaskService = $contactTaskService;
$this->paginator = $this->contactTaskService->getOverviewPaginator('company');
parent::__construct(new Callback([$this, 'onGetItems'], [$this, 'onCount']));
}
示例6: __construct
public function __construct($userCollection)
{
parent::__construct(new ArrayAdapter($userCollection));
}