继我之前的 question ,我仍然无法将 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 Documentation 上的示例,但是我似乎无法让它工作。我的 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 加载到 Bootstrap 中,如下所示:
$configNav = new Zend_Config_Xml('../application/config/navigation.xml', 'navigation');
$navigation = new Zend_Navigation($configNav);
$navView->navigation($navigation);
现在我承认,我在这方面完全搞错了方向,但想法很快就用完了,这已经是漫长的一周了。
谢谢,
授予
最佳答案
Zend_Navigation 似乎通过检查 Controller 、操作和模块键的存在来确定是否使用 Mvc 页面或 Uri 页面;或 uri key 。如果这些条件都不满足,就会生成您报告的错误。您的 XML 文档中的所有示例看起来都很好,所以我猜想稍后在 XML 文件中的某个时间点您会丢失其中一个页面所需的键之一。例如。你有一个 Action 和 Controller 但没有模块。
如果您无法确定是哪一个导致了问题,我建议通过插入以下内容暂时向 Zend_Navigation 添加调试行:
var_dump($options);exit;
进入 Zend/Navigation/Page.php 的第 222 行。这将打印出导致错误的元素的键,这应该可以帮助您确定它是 XML 文档中的哪一个。修复后再次删除此行!
关于php - Zend_Navigation 加载失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2566622/