2015-05-14 24 views
0

我安裝了ZfcRbac而不是BjyAuthorize。 ZendDeveloperTools工具欄部分工作。我無法找到以下警告的原因。我的設置中缺少什麼?ZendDeveloperTools不能與ZfcRbac一起工作

  1. 警告:在C的foreach()提供參數無效:\ dev的\ XAMPP \ htdocs中\ OnlineFieldEvaluation \廠商\ ZF-公地\ ZFC-RBAC \視圖\ Zend的顯影劑工具\工具欄\ zfc-rbac.phtml 94行

  2. 注意:未定義的索引:C:\ dev \ xampp \ htdocs \ OnlineFieldEvaluation \ vendor \ zf-commons \ zfc-rbac \ view \ zend-developer-tools \ toolbar中的警衛\ zfc-rbac.phtml on line 38

  3. 訪客角色
    (!)注意:未定義的索引:用C選項:\ dev的\ XAMPP \ htdocs中\ OnlineFieldEvaluation \廠商\ ZF-公地\ ZFC-RBAC \視圖\ Zend的顯影劑工具\工具欄\上線ZFC-rbac.phtml 19

enter image description here

enter image description here

enter image description here

編輯1: 我改變這部分涉及到Z fcRbac打破了ZendDeveloperTools:

zfc_rbac.global.php

<?php 
/* 
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
* 
* This software consists of voluntary contributions made by many individuals 
* and is licensed under the MIT license. 
*/ 
use ZfcRbac\Guard\GuardInterface; 
/** 
* Copy-paste this file to your config/autoload folder (don't forget to remove the .dist extension!) 
*/ 
return [ 
    'zfc_rbac' => [ 
     /** 
     * Key that is used to fetch the identity provider 
     * 
     * Please note that when an identity is found, it MUST implements the ZfcRbac\Identity\IdentityProviderInterface 
     * interface, otherwise it will throw an exception. 
     */ 
     'identity_provider' => 'ZfcRbac\Identity\AuthenticationIdentityProvider', 
//  'identity_provider' => 'Application\Entity\Systemuser', 
     /** 
     * Set the guest role 
     * 
     * This role is used by the authorization service when the authentication service returns no identity 
     */ 
     'guest_role' => 'guest', 
     /** 
     * Set the guards 
     * 
     * You must comply with the various options of guards. The format must be of the following format: 
     * 
     *  'guards' => [ 
     *   'ZfcRbac\Guard\RouteGuard' => [ 
     *    // options 
     *   ] 
     *  ] 
     */ 
     // 'guards' => [], 
     'guards' => [ 
      'ZfcRbac\Guard\RouteGuard' => [ 
       'zfcuser/login' => ['guest'], 
       'zfcuser' => ['guest'], 
       'home' => ['student'], 

      ], 


     ], 
     /** 
     * As soon as one rule for either route or controller is specified, a guard will be automatically 
     * created and will start to hook into the MVC loop. 
     * 
     * If the protection policy is set to DENY, then any route/controller will be denied by 
     * default UNLESS it is explicitly added as a rule. On the other hand, if it is set to ALLOW, then 
     * not specified route/controller will be implicitly approved. 
     * 
     * DENY is the most secure way, but it is more work for the developer 
     */ 
     'protection_policy' => \ZfcRbac\Guard\GuardInterface::POLICY_DENY, 
     /** 
     * Configuration for role provider 
     * 
     * It must be an array that contains configuration for the role provider. The provider config 
     * must follow the following format: 
     * 
     *  'ZfcRbac\Role\InMemoryRoleProvider' => [ 
     *   'role1' => [ 
     *    'children' => ['children1', 'children2'], // OPTIONAL 
     *    'permissions' => ['edit', 'read'] // OPTIONAL 
     *   ] 
     *  ] 
     * 
     * Supported options depend of the role provider, so please refer to the official documentation 
     */ 
//  'role_provider' => [], 

     'role_provider' => [ 

      'ZfcRbac\Role\ObjectRepositoryRoleProvider' => [ 
       'object_manager' => 'doctrine.entitymanager.orm_default', // alias for doctrine ObjectManager 
       'class_name' => 'Application\Entity\MyHierarchicalRole', 
       'role_name_property' => 'name' 
      ], 

     ], 

     /** 
     * Configure the unauthorized strategy. It is used to render a template whenever a user is unauthorized 
     */ 
     'unauthorized_strategy' => [ 
      /** 
      * Set the template name to render 
      */ 

      'template' => 'error/no-auth' 
     ], 

     /** 
     * Configure the redirect strategy. It is used to redirect the user to another route when a user is 
     * unauthorized 
     */ 
     'redirect_strategy' => [ 
      /** 
      * Enable redirection when the user is connected 
      */ 
      'redirect_when_connected' => true, 

      /** 
      * Set the route to redirect when user is connected (of course, it must exist!) 
      */ 
      'redirect_to_route_connected' => 'zfcuser', 

      /** 
      * Set the route to redirect when user is disconnected (of course, it must exist!) 
      */ 
      'redirect_to_route_disconnected' => 'zfcuser/login', 

      /** 
      * If a user is unauthorized and redirected to another route (login, for instance), should we 
      * append the previous URI (the one that was unauthorized) in the query params? 
      */ 
      'append_previous_uri' => true, 

      /** 
      * If append_previous_uri option is set to true, this option set the query key to use when 
      * the previous uri is appended 
      */ 
      'previous_uri_query_key' => 'redirectTo' 
     ], 

     /** 
     * Various plugin managers for guards and role providers. Each of them must follow a common 
     * plugin manager config format, and can be used to create your custom objects 
     */ 
     // 'guard_manager'    => [], 
     // 'role_provider_manager'  => [] 
    ] 
]; 

這是我zdt.local.php:

<?php 
return array(
    'zenddevelopertools' => array(
     /** 
      * General Profiler settings 
      */ 
     'profiler' => array(
      /** 
      * Enables or disables the profiler. 
      * 
      * Expects: bool 
      * Default: true 
      */ 
      'enabled' => true, 

      /** 
      * Enables or disables the strict mode. If the strict mode is 
      * enabled, any error will throw an exception, otherwise all 
      * errors will be added to the report (and shown in the toolbar). 
      * 
      * Expects: bool 
      * Default: true 
      */ 
      'strict' => true, 

      /** 
      * If enabled, the profiler tries to flush the content before the it 
      * starts collecting data. This option will be ignored if the Toolbar 
      * is enabled. 
      * 
      * Note: The flush listener listens to the MvcEvent::EVENT_FINISH event 
      *  with a priority of -9400. You have to disable this function if 
      *  you wish to modify the output with a lower priority. 
      * 
      * Expects: bool 
      * Default: false 
      */ 
      'flush_early' => false, 

      /** 
      * The cache directory is used in the version check and for every storage 
      * type that writes to the disk. 
      * 
      * Note: The default value assumes that the current working directory is the 
      *  application root. 
      * 
      * Expects: string 
      * Default: 'data/cache' 
      */ 
      'cache_dir' => 'data/cache', 

      /** 
      * If a matches is defined, the profiler will be disabled if the 
      * request does not match the pattern. 
      * 
      * Example: 'matcher' => array('ip' => '127.0.0.1') 
      *   OR 
      *   'matcher' => array('url' => array('path' => '/admin') 
      * 
      * Note: The matcher is not implemented yet! 
      */ 
      'matcher' => array(), 

      /** 
      * Contains a list with all collector the profiler should run. 
      * Zend Developer Tools ships with 'db' (Zend\Db), 'time', 'event', 'memory', 
      * 'exception', 'request' and 'mail' (Zend\Mail). If you wish to disable a default 
      * collector, simply set the value to null or false. 
      * 
      * Example: 'collectors' => array('db' => null) 
      * 
      * Expects: array 
      */ 
      'collectors' => array(), 
     ), 
     /** 
      * General Toolbar settings 
      */ 
     'toolbar' => array(
      /** 
      * Enables or disables the Toolbar. 
      * 
      * Expects: bool 
      * Default: false 
      */ 
      'enabled' => true, 

      /** 
      * If enabled, every empty collector will be hidden. 
      * 
      * Expects: bool 
      * Default: false 
      */ 
      'auto_hide' => false, 

      /** 
      * The Toolbar position. 
      * 
      * Expects: string ('bottom' or 'top') 
      * Default: bottom 
      */ 
      'position' => 'bottom', 

      /** 
      * If enabled, the Toolbar will check if your current Zend Framework version 
      * is up-to-date. 
      * 
      * Note: The check will only occur once every hour. 
      * 
      * Expects: bool 
      * Default: false 
      */ 
      'version_check' => false, 

      /** 
      * Contains a list with all collector toolbar templates. The name 
      * of the array key must be same as the name of the collector. 
      *    * 
      * Example: 'profiler' => array(
      *    'collectors' => array(
      *     // My_Collector_Example::getName() -> mycollector 
      *     'MyCollector' => 'My_Collector_Example', 
      *    ) 
      *   ), 
      *   'toolbar' => array(
      *    'entries' => array(
      *     'mycollector' => 'example/toolbar/my-collector', 
      *    ) 
      *   ), 
      * 
      * Expects: array 
      */ 
      'entries' => array(), 
     ), 
    ), 
); 
+1

你有沒有configiured你的模塊正確遵循該模塊的配置? https://github.com/ZF-Commons/zfc-rbac/tree/master/docs – Hooli

+0

也許,我沒有,但我不明白我錯過了什麼。 – vlr

回答

2

這個問題已經在此之後開始承諾:

https://github.com/zendframework/ZendDeveloperTools/commit/d3432681aa32177a741ad23604a40af9ad454acb

不過,也有等待被合併修復:

https://github.com/ZF-Commons/zfc-rbac/pull/297

在同一拉請求有一個臨時的解決辦法:

我不認爲這已未定,所以作爲臨時的解決方案我 所做的以下變化:在 ./module/Application/config/module.config.php:

在application.config '應用':

然後從./vendor目錄ZFC-rbac.phtml文件複製到 ./module/Application/view/zend-developer-tools/toolbar(注.php必須加載 'ZfcRbac')

在新創建的zfc-rbac中。PHTML,修改最上面幾行看起來 這樣的:

$this->collector->unserialize($this->collector->serialize()); /* @var 
$collection \ZfcRbac\Collector\RbacCollector */ $collection = 
$this->collector->getCollection();