大家好!
我正在学习zf2,并尝试设置导航面板(基于:Zend Framework 2: Zend_Navigation),但电脑的答案仍然是:
An error occurred 执行过程中发生错误;请稍后再试。附加信息:Zend\ServiceManager\Exception\ServiceNotFoundException 文件:/var/www/zf2-tutorial/vendor/zendframework/zendframework/library/Zend/ServiceManager/ServiceManager.php:453 消息:Zend\ServiceManager\ServiceManager::get 无法获取或创建导航实例
module.config.php 包含:
'servicemanager' => array(
'factories' => array(
'navigation' => function($sm) {
$config = $sm->get('Config');
$navigation = new \Zend\Navigation\Navigation($config->get('navigation'));
return $navigation;
}
),
),
我在主 config/autoload 文件夹中有一个 application.global.php,如下所示:
<?php
return array(
// All navigation-related configuration is collected in the 'navigation' key
'navigation' => array(
// The DefaultNavigationFactory we configured in (1) uses 'default' as the sitemap key
'default' => array(
// And finally, here is where we define our page hierarchy
'Album' => array(
'label' => 'Albumlista',
'route' => 'album',
'action' => 'index',
'pages' => array(
array(
'label' => 'Add',
'route' => 'album',
'action' => 'add'
)
)
),
'Application' => array(
'label' => 'Alap alkalmazás',
'route' => 'application',
'action' => 'index',
)
),
),
);
从控制器我给出这个命令:
$config = $this->getServiceLocator()->get('navigation');
有人可以帮我解决这个问题吗?我读到了http://adam.lundrigan.ca/2012/07/quick-and-dirty-zf2-zend-navigation/,我试过了,我做到了,但我想与 acl 结合,这样我写了这个问题。
感谢您的每一个帮助!