diff --git a/src/Acl.php b/src/Acl.php index 8211070..80717b1 100644 --- a/src/Acl.php +++ b/src/Acl.php @@ -566,9 +566,11 @@ public function setRule($operation, $type, $roles = null, $resources = null, $resources = array(); foreach ($resourcesTemp as $resource) { if (null !== $resource) { - $children = $this->getChildResources($this->getResource($resource)); + $resourceObj = $this->getResource($resource); + $resourceId = $resourceObj->getResourceId(); + $children = $this->getChildResources($resourceObj); $resources = array_merge($resources, $children); - $resources[$resource] = $this->getResource($resource); + $resources[$resourceId] = $resourceObj; } else { $resources[] = null; } diff --git a/test/AclTest.php b/test/AclTest.php index b8788f5..d4b0317 100644 --- a/test/AclTest.php +++ b/test/AclTest.php @@ -1328,4 +1328,15 @@ public function testAclResourcePermissionsAreInheritedWithMultilevelResourcesAnd $this->assertFalse($this->_acl->isAllowed('guest', 'post_1', 'comment')); $this->assertFalse($this->_acl->isAllowed('guest', 'post_2', 'comment')); } + + public function testSetRuleWorksWithResourceInterface() + { + $roleGuest = new Role\GenericRole('guest'); + $this->_acl->addRole($roleGuest); + + $resourceFoo = new Resource\GenericResource('foo'); + $this->_acl->addResource($resourceFoo); + + $this->_acl->setRule(Acl\Acl::OP_ADD, Acl\Acl::TYPE_ALLOW, $roleGuest, $resourceFoo); + } }