/** * 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); } }
/** * @covers PagingInfo::getRecordsPerPage */ public function testGetRecordsPerPage() { $this->paging->setRecordsPerPage(27); $this->assertSame(27, $this->paging->getRecordsPerPage()); }
protected function setUp() { $this->paging = new \PagingInfo(); $this->paging->setRecordsPerPage(5); }
/** * 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; }