De hecho para probar lo que digo hice esta prueba, el controller:
Código PHP:
Ver original<?php
namespace Album\Controller;
use Album\Model\DbTable\AlbumTable,
Zend\Mvc\Controller\ActionController,
Zend\Paginator\Paginator,
Zend\View\Helper\PaginationControl,
Zend\View\Renderer;
class ListController extends ActionController
{
protected $albumTable;
protected $view;
public function setView(\Zend\View\Renderer $view)
{
$this->view = $view;
return $this;
}
public function getView()
{
return $this->view;
}
public function setAlbumTable(AlbumTable $albumTable)
{
$this->albumTable = $albumTable;
return $this;
}
public function getAlbumTable()
{
return $this->albumTable;
}
public function indexAction()
{
$albums = $this->getAlbumTable()->fetchAll();
$matches = $this->getEvent()->getRouteMatch();
$nPage = $matches->getParam('page', 1);
PaginationControl::setDefaultViewPartial('paginator.phtml');
$paginator = Paginator::factory($albums);
$paginator->setDefaultItemCountPerPage(5);
$paginator->setCurrentPageNumber($nPage);
$paginator->setView($this->getView());
return array('albums' => $paginator); }
}
El DI:
Código PHP:
Ver original 'album-list' => 'Album\Controller\ListController'
),
'Album\Controller\ListController' => array ( 'albumTable' => 'Album\Model\DbTable\AlbumTable',
'view' => 'view'
)
),
La vista:
Código PHP:
Ver original<h1>Albums</h1>
<ul>
<?php foreach ($this->albums as $album) { ?>
<li><?php echo $album->album_id; ?> - <?php echo $album->album; ?></li>
<?php } ?>
</ul>
<?php echo $this->albums; ?>
y funciona correctamente