/** * @covers PagingInfo::setPageNumber */ public function testSetPageNumber() { $this->paging = new \PagingInfo(); $this->assertEquals(0, $this->paging->getPageNumber()); $this->paging->setPageNumber(20); $this->assertSame(20, $this->paging->getPageNumber()); }
/** * Initialize the 'pagingInfo' based on parameters that may exist in the * request, or using default values. * * @param Context $ctx */ private function initPagingInfo($ctx) { $offset = $ctx->getRequest()->getLong('iDisplayStart', 0); $pageSize = $ctx->getRequest()->getLong('iDisplayLength', 10); if ($pageSize > 0) { // if pagination is turned off, iDisplayLength is set to -1 by datatables $this->pagingInfo->setPageNumber($offset / $pageSize); $this->pagingInfo->setRecordsPerPage($pageSize); } }
/** * Create a new PagingInfo object, populate with data from the Request. * * @param Context $ctx */ private function createPagingInfo($ctx) { $pagingInfoPrefs = new PagingInfoPrefs($ctx, $this->getName()); $pagingInfo = new PagingInfo(); if ($pagingInfoPrefs->getPageNumber() >= 0) { $pagingInfo->setPageNumber($pagingInfoPrefs->getPageNumber()); } if ($pagingInfoPrefs->getRecodsPerPage() > 0) { $pagingInfo->setRecordsPerPage($pagingInfoPrefs->getRecodsPerPage()); } if ($pagingInfoPrefs->getOrderByColumn() != '') { $pagingInfo->setOrderByColumn($pagingInfoPrefs->getOrderByColumn()); $pagingInfo->setOrderByAscending($pagingInfoPrefs->isOrderByAscending()); } return $pagingInfo; }