我想在 Skeleton Application (ZF2) 中建立一个菜单。我做了一个单独的模块Navigation
。在 Navigation Controller 写了一段代码:
namespace Navigation\Controller;
use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;
use Zend\Navigation\Navigation;
class NavigationController extends AbstractActionController
{
public function indexAction()
{
$container = new \Zend\Navigation\Navigation(array(
array(
'label' => 'Album',
'controller' => 'album',
'action' => 'index',
'route' => 'album',
)
));
$navigation = new \Zend\View\Helper\Navigation\Menu();
$navigation->renderMenu($container);
return new ViewModel(array('navigation'=>$navigation));
}}
并得到错误:
Zend\Navigation\Page\Mvc::getHref cannot execute as no Zend\Mvc\Router\RouteStackInterface instance is composed
在文件:\vendor\zendframework\zendframework\library\Zend\Navigation\Page\Mvc.php:186
怎么解决?