{"action":"closed","issue":{"url":"https://api.github.com/repos/ZF-Commons/zfc-rbac/issues/295","labels_url":"https://api.github.com/repos/ZF-Commons/zfc-rbac/issues/295/labels{/name}","comments_url":"https://api.github.com/repos/ZF-Commons/zfc-rbac/issues/295/comments","events_url":"https://api.github.com/repos/ZF-Commons/zfc-rbac/issues/295/events","html_url":"https://github.com/ZF-Commons/zfc-rbac/issues/295","id":74417165,"number":295,"title":"Problème avec mon CustomRoleProvider","user":{"login":"Shishi666","id":11406878,"avatar_url":"https://avatars.githubusercontent.com/u/11406878?v=3","gravatar_id":"","url":"https://api.github.com/users/Shishi666","html_url":"https://github.com/Shishi666","followers_url":"https://api.github.com/users/Shishi666/followers","following_url":"https://api.github.com/users/Shishi666/following{/other_user}","gists_url":"https://api.github.com/users/Shishi666/gists{/gist_id}","starred_url":"https://api.github.com/users/Shishi666/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Shishi666/subscriptions","organizations_url":"https://api.github.com/users/Shishi666/orgs","repos_url":"https://api.github.com/users/Shishi666/repos","events_url":"https://api.github.com/users/Shishi666/events{/privacy}","received_events_url":"https://api.github.com/users/Shishi666/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2015-05-08T16:23:38Z","updated_at":"2015-09-09T03:21:27Z","closed_at":"2015-09-09T03:21:27Z","body":"Hello I have perhaps not understood the doc but I have declared this in my zfc_rbac.global.php file :\r\n```php\r\n'role_provider_manager' => [\r\n    'factories' => [\r\n        'role_db_provider'  =>  'ShishiUser\\Factory\\RoleProviderFactory', \r\n     ]\r\n], \r\n'role_provider' => [\r\n    'role-db-provider' => [\r\n    ], \r\n], \r\n```\r\nMy factory : \r\n```php\r\n<?php\r\nnamespace ShishiUser\\Factory;\r\n\r\nuse Zend\\ServiceManager\\FactoryInterface;\r\nuse ShishiUser\\Role\\RoleDbProvider;\r\nclass RoleProviderFactory implements FactoryInterface\r\n{\r\n /* (non-PHPdoc)\r\n     * @see \\Zend\\ServiceManager\\FactoryInterface::createService()\r\n     */\r\n    public function createService(\\Zend\\ServiceManager\\ServiceLocatorInterface $serviceLocator)\r\n    {\r\n        // TODO Auto-generated method stub\r\n        $sm = $serviceLocator->get('ServiceManager');\r\n        $roleRepository = $sm->get('shishi-user-role-repository');\r\n        $roleDbProvider = new RoleDbProvider();\r\n        $roleDbProvider->setRoleRepository($roleRepository);\r\n        return $roleDbProvider;\r\n    }\r\n}\r\n?>\r\n```\r\nAnd the RoleProviderClass : \r\n```php\r\n<?php\r\nnamespace ShishiUser\\Role;\r\n\r\nuse ZfcRbac\\Role\\RoleProviderInterface;\r\nuse ShishiUser\\Repository\\RoleRepository;\r\nuse ZfcRbac\\Exception\\RoleNotFoundException;\r\nuse Rbac\\Role\\HierarchicalRole;\r\nuse Rbac\\Role\\Role;\r\nclass RoleDbProvider implements RoleProviderInterface{\r\n    public $roleRepository;\r\n    public function getRoles(array $roleNames)\r\n    {\r\n         $roles = $this->roleRepository->findByLibelles($roleNames);\r\n        $rbacRoles = [];\r\n        if (count($roles) >= count($roleNames)) {\r\n            foreach ($roles as $role){\r\n                if ($role->getChilds() !== null){\r\n                    $rbacRole = new HierarchicalRole($role->getRol_libelle());\r\n                    foreach ( (array) $role->getChilds() as $childRole){\r\n                        $rbacRole->addChild($childRole);\r\n                    }\r\n                }else{\r\n                    $rbacRole = new Role($role->getRol_libelle());\r\n                }\r\n                $permissions = ($role->getRol_permissions() !== null) ? [] : $role->getRol_permissions();\r\n                if ($role->getRol_permissions() !== null){\r\n                    foreach ($permissions as $permission){\r\n                        $rbacRole->addPermission($permission->getPerm_libelle());\r\n                    }\r\n                }\r\n                $rbacRoles[] = $rbacRole;\r\n            }\r\n            return $rbacRoles;\r\n        }\r\n        // We have roles that were asked but couldn't be found in database... problem!\r\n        foreach ($roles as &$role) {\r\n            $role = $role->getName();\r\n        }\r\n        throw new RoleNotFoundException(sprintf('Some roles were asked but could not be loaded from database: %s', implode(', ', array_diff($roleNames, $roles))));\r\n    }\r\n    public function setOptions($options)\r\n    {\r\n        $this->options = $options;\r\n        return $this;\r\n    }\r\n    public function setRoleRepository(RoleRepository $roleRepository)\r\n    {\r\n        $this->roleRepository = $roleRepository;\r\n        return $this;\r\n    }\r\n}\r\n?>\r\n```\r\n\r\nand i obtain this error : \r\n\r\nFatal error: Uncaught exception 'Zend\\ServiceManager\\Exception\\ServiceNotFoundException' with message 'ZfcRbac\\Role\\RoleProviderPluginManager::get was unable to fetch or create an instance for role-db-provider'\r\n\r\n\r\nI try to retrieve roles from my database, could you explain me what I am doing wrong please?\r\nThank you in advance\r\ncordially"}}