ZF-Commons / zfc-rbac

Role-based access control module to provide additional features on top of Zend\Permissions\Rbac
BSD 3-Clause "New" or "Revised" License
181 stars 111 forks source link

Firewalls instantiation in RbacFactory #55

Closed isisis closed 10 years ago

isisis commented 11 years ago

Hey.

Why are the Firewalls not being created by a factory method receiving the service locator, like it's done for providers ?

I am especially using the controller firewall. I did set up everything for working with doctrine entities. My rules need also to be created with entities from database. I need the service locator for it in order to inject my "RuleRepository" into firewall.

My suggestion for making this possible is to change ZfcRbac\Service\RbacFactory like this. Line 26 -28 from: foreach($options->getFirewalls() as $class => $config) { $rbac->addFirewall(new $class($config)); } To: foreach($options->getFirewalls() as $class => $config) {
$rbac->addFirewall($class::factory($sl, $config)); }

Let me know if theres another way to do this or if I could help you to improve ZfcRbac (with my beginner knowledge).

bakura10 commented 11 years ago

Hi,

You're right. Every object should be created through service locator. Ideally, this is something that should be refactored to have plugin managers to create firewalls.

A refactor of BjyAuthorize that will include ZfcRbac is on the road, this is something I'll keep in my head ;-).

jmleroux commented 11 years ago

A refactor of BjyAuthorize that will include ZfcRbac is on the road, this is something I'll keep in my head ;-).

Still valid ?

bakura10 commented 10 years ago

Hi @isisis ,

This has been fixed in refactor (currently in the "refactor" branch as I'm waiting for ZF 2.3 which will be minimum dependency). Everything now use plugin managers for proper injection.

isisis commented 10 years ago

Hi @bakura10.

Great ! You're doing a good job :-) Has been a while now and I will have to dig into the code again. I'm using this in an ERP System I am developing and had a lot of other stuff to do in the last months.

bakura10 commented 10 years ago

Yes, sorry it has took a long time to fix this :D. But I now have a very solid and clean architecture so everything should be easier :).