/** * 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(); }
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); }