4

继我之前的问题之后,我仍然在将 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);

现在我承认我完全搞错了,但很快就没有想法了,这是漫长的一周。

谢谢,

授予

4

2 回答 2

3

Zend_Navigation 似乎通过检查控制器、动作和模块键的存在来确定是否使用 Mvc 页面或 Uri 页面;或 uri 键。如果这些条件都不满足,则会生成您报告的错误。您的 XML 文档中的所有示例看起来都很好,所以我猜想稍后在 XML 文件中的某个时间点,您缺少一个页面所需的键之一。例如,您有一个动作和控制器,但没有模块。

如果您无法确定是哪一个导致了问题,我建议您通过插入暂时向 Zend_Navigation 添加一个调试行:

var_dump($options);exit;

进入 Zend/Navigation/Page.php 的第 222 行。这将打印出导致错误的元素的键,这将帮助您确定它是 XML 文档中的哪一个。修复后再次删除此行!

于 2010-04-02T13:57:01.023 回答
1

最近,当我不小心为其中一个页面添加了 2 个条目时,我也遇到了这个错误。

于 2013-08-20T21:34:36.513 回答