Skip to content
This repository has been archived by the owner on May 14, 2018. It is now read-only.

Missing instance/object for parameter rules for BjyAuthorize\Guard\Controller #78

Closed
nXqd opened this issue Feb 11, 2013 · 1 comment
Closed

Comments

@nXqd
Copy link
Contributor

nXqd commented Feb 11, 2013

My configuration :

<?php

return array(
  'bjyauthorize' => array(

    // set the 'guest' role as default (must be defined in a role provider)
    'default_role' => 'guest',

    /* this module uses a meta-role that inherits from any roles that should
     * be applied to the active user. the identity provider tells us which
     * roles the "identity role" should inherit from.
     *
     * for ZfcUser, this will be your default identity provider
     */
    'identity_provider' => 'BjyAuthorize\Provider\Identity\ZfcUserZendDb',

    /* role providers simply provide a list of roles that should be inserted
     * into the Zend\Acl instance. the module comes with two providers, one
     * to specify roles in a config file and one to load roles using a
     * Zend\Db adapter.
     */
    'role_providers' => array(

      /* here, 'guest' and 'user are defined as top-level roles, with
       * 'admin' inheriting from user
       */
      'BjyAuthorize\Provider\Role\Config' => array(
        'guest' => array(),
        'user'  => array('children' => array(
          'admin' => array(),
        )),
      ),

      // this will load roles from the user_role table in a database
      // format: user_role(role_id(varchar), parent(varchar))
      'BjyAuthorize\Provider\Role\ZendDb' => array(
        'table'             => 'user_role',
        'role_id_field'     => 'role_id',
        'parent_role_field' => 'parent',
      ),
    ),

    // resource providers provide a list of resources that will be tracked
    // in the ACL. like roles, they can be hierarchical
    'resource_providers' => array(
      'BjyAuthorize\Provider\Resource\Config' => array(
        'pants' => array(),
      ),
    ),

    'rule_providers' => array(
      'BjyAuthorize\Provider\Rule\Config' => array(
        'allow' => array(
          array(array('guest', 'user'), 'pants', 'wear')
        ),

        'deny' => array(
        ),
      ),
    ),

    'guards' => array(
      'BjyAuthorize\Guard\Controller' => array(
        array('controller' => 'Main\Controller\UserController', 'action' => 'get', 'roles' => array('user')),
      ),
    ),
  ),
);

The errors :

Fatal error: Uncaught exception 'Zend\Di\Exception\MissingPropertyException' with message 'Missing instance/object for parameter rules for BjyAuthorize\Guard\Controller::__construct' in /vagrant/gift_portal/backend/zf2/vendor/zendframework/zendframework/library/Zend/Di/Di.php:699
Stack trace:
#0 /vagrant/gift_portal/backend/zf2/vendor/zendframework/zendframework/library/Zend/Di/Di.php(393): Zend\Di\Di->resolveMethodParameters('BjyAuthorize\Gu...', '__construct', Array, NULL, true, true)
#1 /vagrant/gift_portal/backend/zf2/vendor/zendframework/zendframework/library/Zend/Di/Di.php(225): Zend\Di\Di->createInstanceViaConstructor('BjyAuthorize\Gu...', Array, NULL)
#2 /vagrant/gift_portal/backend/zf2/vendor/zendframework/zendframework/library/Zend/Di/Di.php(174): Zend\Di\Di->newInstance('BjyAuthorize\Gu...', Array, true)
#3 /vagrant/gift_portal/backend/zf2/vendor/zendframework/zendframework/library/Zend/ServiceManager/Di/DiServiceFactory.php(104): Zend\Di\Di->get('BjyAuthorize\Gu...', Array)
#4 /vagrant/gift_portal/backend/zf2/ in /vagrant/gift_portal/backend/zf2/vendor/zendframework/zendframework/library/Zend/ServiceManager/ServiceManager.php on line 749
@Ocramius
Copy link
Contributor

You have Di configuration setup. Duplicate of #59

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants