Zend_Navigation 无法加载
继我之前的问题之后,我在将 xml 文件加载到 Zend_Navigation 时仍然遇到问题。
我现在收到以下错误消息:
<b>Fatal error</b>: Uncaught exception 'Zend_Navigation_Exception' with message 'Invalid argument: Unable to determine class to instantiate' in C:\www\mysite\development\website\library\Zend\Navigation\Page.php:223
我试图使我的 navigation.xml 文件看起来与 Zend 文档,但是我似乎无法让它工作。我的 XML 文件如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<configdata>
<navigation>
<default>
<label>Home</label>
<controller>index</controller>
<action>index</action>
<module>default</module>
<pages>
<tour>
<label>Tour</label>
<controller>tour</controller>
<action>index</action>
<module>default</module>
</tour>
<blog>
<label></label>
<uri>http://blog.mysite.com</uri>
</blog>
<support>
<label>Support</label>
<controller>support</controller>
<action>index</action>
<module>default</module>
</support>
</pages>
</default>
<users>
<label>Home</label>
<controller>index</controller>
<action>index</action>
<module>users</module>
<role>guser</role>
<resource>owner</resource>
<pages>
<jobmanger>
<label>Job Manager</label>
<controller>jobmanager</controller>
<action>index</action>
<module>users</module>
<role>guser</role>
<resource>owner</resource>
</jobmanger>
<myaccount>
<label>My Account</label>
<controller>profile</controller>
<action>index</action>
<role>guser</role>
<resource>owner</resource>
<module>users</module>
<pages>
<detail>
<label>Account Details</label>
<controller>profile</controller>
<action>detail</action>
<module>users</module>
<role>guser</role>
<resource>owner</resource>
<pages>
<history>
<label>Account History</label>
<controller>profile</controller>
<action>history</action>
<module>users</module>
<role>guser</role>
<resource>owner</resource>
</history>
<password>
<label>Change Password</label>
<controller>profile</controller>
<action>changepwd</action>
<module>users</module>
<role>employer</role>
<resource>employers</resource>
</password>
</pages>
</detail>
...
</navigation>
</configdata>
我正在将此 xml 加载到引导程序中,如下所示:
$configNav = new Zend_Config_Xml('../application/config/navigation.xml', 'navigation');
$navigation = new Zend_Navigation($configNav);
$navView->navigation($navigation);
现在我承认我完全搞错了,但很快就没有想法了,而且这已经是漫长的一周了。
谢谢,
格兰特
Following on from my earlier question, I am still having issues with loading the xml file into Zend_Navigation.
I am now getting the following error message:
<b>Fatal error</b>: Uncaught exception 'Zend_Navigation_Exception' with message 'Invalid argument: Unable to determine class to instantiate' in C:\www\mysite\development\website\library\Zend\Navigation\Page.php:223
I've tried to make my navigation.xml file look similar to the example on the Zend Documentation, However I just can't seem to get it to work. My XML file looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<configdata>
<navigation>
<default>
<label>Home</label>
<controller>index</controller>
<action>index</action>
<module>default</module>
<pages>
<tour>
<label>Tour</label>
<controller>tour</controller>
<action>index</action>
<module>default</module>
</tour>
<blog>
<label></label>
<uri>http://blog.mysite.com</uri>
</blog>
<support>
<label>Support</label>
<controller>support</controller>
<action>index</action>
<module>default</module>
</support>
</pages>
</default>
<users>
<label>Home</label>
<controller>index</controller>
<action>index</action>
<module>users</module>
<role>guser</role>
<resource>owner</resource>
<pages>
<jobmanger>
<label>Job Manager</label>
<controller>jobmanager</controller>
<action>index</action>
<module>users</module>
<role>guser</role>
<resource>owner</resource>
</jobmanger>
<myaccount>
<label>My Account</label>
<controller>profile</controller>
<action>index</action>
<role>guser</role>
<resource>owner</resource>
<module>users</module>
<pages>
<detail>
<label>Account Details</label>
<controller>profile</controller>
<action>detail</action>
<module>users</module>
<role>guser</role>
<resource>owner</resource>
<pages>
<history>
<label>Account History</label>
<controller>profile</controller>
<action>history</action>
<module>users</module>
<role>guser</role>
<resource>owner</resource>
</history>
<password>
<label>Change Password</label>
<controller>profile</controller>
<action>changepwd</action>
<module>users</module>
<role>employer</role>
<resource>employers</resource>
</password>
</pages>
</detail>
...
</navigation>
</configdata>
I am loading this xml into the bootstrap as follows:
$configNav = new Zend_Config_Xml('../application/config/navigation.xml', 'navigation');
$navigation = new Zend_Navigation($configNav);
$navView->navigation($navigation);
Now I confess that I've totally got the wrong end of the stick with this, but rapidly running out of ideas, and it's been a long week.
Thanks,
Grant
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Zend_Navigation 似乎通过检查控制器、操作和模块键是否存在来确定是否使用 Mvc 页面或 Uri 页面;或 uri 键。如果这两个条件都不满足,则会生成您报告的错误。 XML 文档中的所有示例看起来都很好,因此我猜想在 XML 文件的稍后某个时刻,您丢失了其中一个页面所需的键之一。例如,您有一个操作和控制器,但没有模块。
如果您无法找出导致问题的原因,我建议通过
在 Zend/Navigation/Page.php 的第 222 行中插入: 临时向 Zend_Navigation 添加调试行。这将打印出导致错误的元素的键,这应该可以帮助您找出 XML 文档中的哪个元素。修复后再次删除此行!
Zend_Navigation appears to determine whether or not to use an Mvc page or Uri page by checking for the existence of either the controller, action and module keys; or a uri key. The error you're reporting is generated if neither of these conditions are met. All of the examples in your XML document look fine, so I would guess that a some point later in the XML file you are missing one of the required keys for one of your pages. E.g. you have an action and controller but no module.
If you aren't able to spot which one is causing the problem, I would suggest temporarily adding a debug line to Zend_Navigation by inserting:
into line 222 of Zend/Navigation/Page.php. This would print out the keys for the element that is causing the error, which should help you work out which one in your XML doc it is. Remove this line again once you've fixed it!
最近,当我不小心为其中一个页面添加了 2 个条目时,我也遇到了这个错误。
I also had this error recently when I had accidentally added 2 entries for one of the pages.