Example #1
0
 public function __construct(DibiDataSource $datasource, $itemsPerPage = 20)
 {
     $this->datasource = $datasource;
     $this->itemsPerPage = $itemsPerPage;
     $this->getPaginator();
     parse_str($_SERVER['QUERY_STRING'], $vars);
     if (isset($vars[$this->var_name])) {
         $this->paginator->setPage($vars[$this->var_name]);
     }
     unset($vars[$this->var_name]);
     $this->url = $_SERVER['SCRIPT_NAME'] . '?' . http_build_query($vars);
     $this->paginator->setItemsPerPage($this->itemsPerPage);
     $this->paginator->setItemCount(count($this->datasource));
 }
Example #2
0
 /**
  * @covers Hermes\Resource\Paginator::getNextPage
  */
 public function testGetNextPage()
 {
     $this->object->setPage(1);
     $this->assertSame(2, $this->object->getNextPage());
 }