Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/google-chrome/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Zend Navigation&;递归Zend Acl_Php_Zend Framework_Zend Navigation_Zend Acl - Fatal编程技术网

Php Zend Navigation&;递归Zend Acl

Php Zend Navigation&;递归Zend Acl,php,zend-framework,zend-navigation,zend-acl,Php,Zend Framework,Zend Navigation,Zend Acl,我想使用基于Zend_Acl的Zend_导航进行导航 下面是我的navigation.xml文件的一部分,位于/application/configs dir中 <?xml version="1.0" encoding="UTF-8"?> <config> <nav> <menu1> <label>solidData</label> <uri>

我想使用基于Zend_Acl的Zend_导航进行导航 下面是我的navigation.xml文件的一部分,位于/application/configs dir中

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <nav>
        <menu1>
            <label>solidData</label>
            <uri>#</uri>
            <pages>
                <service>
                    <label>menuLabel1</label>
                    <controller>service</controller>
                    <action>index</action>
                    <resource>service</resource>
                    <privilege>index</privilege>
                </service>
                <attendance>
                    <label>menuLabel2</label>
                    <controller>attendance</controller>
                    <action>index</action>
                    <resource>attendance</resource>
                    <privilege>index</privilege>
                </attendance>
            </pages>
        </menu1>
        <menu2>
            <label>systemData</label>
            <uri>#</uri>
            <pages>
                <users>
                    <label>users</label>
                    <controller>users</controller>
                    <action>index</action>
                    <resource>users</resource>
                    <privilege>index</privilege>
                </users>
                <profile>
                    <label>profiles</label>
                    <controller>profile</controller>
                    <action>index</action>
                    <resource>profile</resource>
                    <privilege>index</privilege>
                </profile>
                <dictionary>
                    <label>dictionary</label>
                    <controller>dictionary</controller>
                    <action>index</action>
                    <resource>dictionary</resource>
                    <privilege>index</privilege>
                </dictionary>
                <language>
                    <label>languages</label>
                    <controller>language</controller>
                    <action>index</action>
                    <resource>language</resource>
                    <privilege>index</privilege>
                </language>
            </pages>
        </menu2>
    </nav>
</config>
编辑

好的,但是如果我改变菜单的结构,我也必须改变ACL。
在我的ACL资源控制器中,权限是contoller中的操作。

我不确定我是否理解正确,但为什么您不在
中拥有一个资源,并拒绝这些用户访问该资源,或者拒绝其他用户访问该资源?您可能必须更改ACL架构以捕获此类事件,但不能更改导航

更新 试着回答第二个问题:

<menu2>
    <label>systemData</label>
    <uri>#</uri>
    <resource>systemData</resource>
    <pages>
        ...
    </pages>
</menu2>

系统数据
#
系统数据
...

资源只是一个标识符,所以您不应该(不能)向一个对象添加两个资源。您不必担心导航中的访问逻辑,而是提供ACL使用的信息。当然,在ACL中,您需要添加更多的逻辑,以便将权限分配给正确的资源

即标记特权?也许吧

       $this->allow($guest, array('login', 'register'), array('view', 'guest:login', 'guest:register'));
   $this->allow('user', array('logout', new Zfcms_Acl_Resource_News, 'content'), array('view', 'browse', 'latest', 'submit', 'save', 'editown', 'deleteown'));
   $this->allow('admin', array('admin:area'), array('admin:view', 'admin:edit', 'admin:delete', 'admin:summary'));
   $this->allow('admin');
   $this->deny($guest, new Zfcms_Acl_Resource_News, array('save'));
   /**
    * The below prevents logged users from seeing the login/register tabs
    */
   $this->deny(new Zfcms_Acl_Role_User(), null, array('guest:login', 'guest:register'));

我同意,向
添加资源和权限,并限制对ACL页面中导航项的访问,因为这些页面属于不同的资源,因此我无法向其中添加任何资源。这不是解决方案OK,但如果我更改菜单结构,我还必须更改ACL。在“我的ACL资源是控制器”中,“权限是控件中的操作”您不必更改菜单的结构,只需添加正确的资源名称,您的ACL就可以找到匹配项。您必须在ACL中进行更改,以寻址正确的资源。这可能会有帮助,我的意思是我想从一页移动到另一页。我不知道你说“你不必改变菜单结构”是什么意思
Invalid argument: $resource must be null, a string,  or an instance of Zend_Acl_Resource_Interface
<menu2>
    <label>systemData</label>
    <uri>#</uri>
    <resource>systemData</resource>
    <pages>
        ...
    </pages>
</menu2>
       $this->allow($guest, array('login', 'register'), array('view', 'guest:login', 'guest:register'));
   $this->allow('user', array('logout', new Zfcms_Acl_Resource_News, 'content'), array('view', 'browse', 'latest', 'submit', 'save', 'editown', 'deleteown'));
   $this->allow('admin', array('admin:area'), array('admin:view', 'admin:edit', 'admin:delete', 'admin:summary'));
   $this->allow('admin');
   $this->deny($guest, new Zfcms_Acl_Resource_News, array('save'));
   /**
    * The below prevents logged users from seeing the login/register tabs
    */
   $this->deny(new Zfcms_Acl_Role_User(), null, array('guest:login', 'guest:register'));