编程语言
首页 > 编程语言> > php – Zend_Navigation无法加载

php – Zend_Navigation无法加载

作者:互联网

继我早期的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似乎通过检查控制器,操作和模块密钥是否存在来确定是否使用Mvc页面或Uri页面;或者是一把钥匙.如果未满足这些条件,则会生成您报告的错误.您的XML文档中的所有示例都很好,所以我猜想在XML文件中稍后您缺少其中一个页面所需的键之一.例如.你有一个动作和控制器,但没有模块.

如果您无法找到导致问题的原因,我建议通过插入以下内容临时向Zend_Navigation添加调试行:

var_dump($options);exit;

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

标签:php,zend-framework,zend-navigation
来源: https://codeday.me/bug/20190627/1300331.html