Ejemplo n.º 1
0
 /**
  * Magic method called when object is called as a function.
  *
  * @param int   $currentPageNo
  * @param int   $rowsPerPage
  * @param int   $totalRowCount
  * @param array $options
  * @return Paginator
  */
 public function __invoke($currentPageNo, $rowsPerPage, $totalRowCount, array $options = [])
 {
     if (!$this->view || !$this->view->getRequest()) {
         throw new \LogicException('View request is required for this view helper');
     }
     $paginator = new Paginator($currentPageNo, $rowsPerPage, $totalRowCount, $this->view->getRequest(), $options);
     return $paginator->getHtml();
 }
Ejemplo n.º 2
0
 public function testGetHtmlUrlGenerator()
 {
     $paginator = new Paginator(1, 10, 20, function ($page) {
         return 'http://example.org/some-page.html?page=' . $page;
     });
     $html = $paginator->getHtml();
     $this->assertContains('href="http://example.org/some-page.html?page=1"', $html);
     $this->assertContains('href="http://example.org/some-page.html?page=2"', $html);
 }