Reputation: 801
i need a pagination control helper inside my controller that return JsonModel and not simple view.
this is the code
$paginationHelper = new \Zend\View\Helper\PaginationControl();
$paginationHelper->setView(new PhpRenderer());
$paginationTxt = $paginationHelper(
$pagination,
'Sliding',
array('user/user/pagination', 'User'),
array('route' => 'user', 'action' => $action)
);
$pagination is instance of Zend\Paginator\Paginator
the error is
No paginator instance provided or incorrect type
if i put the code inside view all work fine
edit1:
i tried
$view = new PhpRenderer();
$view->paginationControl($pagination,
'Sliding',
array('user/user/pagination', 'User'),
array('route' => 'user', 'action' => $action));
same result
i change code in this way
$paginationHelper->setDefaultViewPartial('pagination.phtml');
$paginationTxt = $paginationHelper($pagination,
'Sliding',
null,
array('route' => 'user', 'action' => $action));
all work fine
Upvotes: 0
Views: 753
Reputation: 785
Get it using the ViewHelperManager
$viewHelperManager = $this->getServiceLocator()->get('ViewHelperManager');
$paginationHelper = $viewHelperManager->get('paginationControl');
Upvotes: 1