Permalink
Browse files

[zen-27] Renamed interfaces in Zend\Acl

  • Loading branch information...
1 parent 45546b1 commit 12c8e7deea20cd1d89cf8c1938a3eb128d9504bb @gabriel403 gabriel403 committed Apr 8, 2012
View

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -44,5 +44,5 @@
* @param string $privilege
* @return boolean
*/
- public function assert(Acl $acl, Role $role = null, Resource $resource = null, $privilege = null);
+ public function assert(Acl $acl, Role\RoleInterface $role = null, Resource\ResourceInterface $resource = null, $privilege = null);
}
@@ -18,7 +18,7 @@
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
-namespace Zend\Acl;
+namespace Zend\Acl\Exception;
/**
* @uses Zend\Exception
@@ -27,5 +27,5 @@
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
-interface Exception
+interface ExceptionInterface
{}
@@ -4,7 +4,7 @@
class InvalidArgumentException
extends \InvalidArgumentException
- implements \Zend\Acl\Exception
+ implements \Zend\Acl\Exception\ExceptionInterface
{
}
@@ -4,7 +4,7 @@
class RuntimeException
extends \RuntimeException
- implements \Zend\Acl\Exception
+ implements \Zend\Acl\Exception\ExceptionInterface
{
}
@@ -20,7 +20,7 @@
namespace Zend\Acl\Resource;
-use Zend\Acl\Resource;
+use Zend\Acl\Resource\ResourceInterface;
/**
* @uses \Zend\Acl\Resource\ResourceInterface
@@ -29,7 +29,7 @@
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
-class GenericResource implements Resource
+class GenericResource implements ResourceInterface
{
/**
* Unique id of Resource
@@ -18,15 +18,15 @@
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
-namespace Zend\Acl;
+namespace Zend\Acl\Resource;
/**
* @category Zend
* @package Zend_Acl
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
-interface Resource
+interface ResourceInterface
{
/**
* Returns the string identifier of the Resource
@@ -20,7 +20,7 @@
namespace Zend\Acl\Role;
-use Zend\Acl\Role;
+use Zend\Acl\Role\RoleInterface;
/**
* @uses Zend\Acl\Role
@@ -29,7 +29,7 @@
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
-class GenericRole implements Role
+class GenericRole implements RoleInterface
{
/**
* Unique id of Role
@@ -50,7 +50,7 @@ public function __construct($roleId)
}
/**
- * Defined by Zend\Acl\Role; returns the Role identifier
+ * Defined by Zend\Acl\Role\RoleInterface; returns the Role identifier
*
* @return string
*/
@@ -60,7 +60,7 @@ public function getRoleId()
}
/**
- * Defined by Zend\Acl\Role; returns the Role identifier
+ * Defined by Zend\Acl\Role\RoleInterface; returns the Role identifier
* Proxies to getRoleId()
*
* @return string
@@ -56,12 +56,12 @@ class Registry
* will have the least priority, and the last parent added will have the
* highest priority.
*
- * @param \Zend\Acl\Role $role
- * @param \Zend\Acl\Role|string|array $parents
+ * @param \Zend\Acl\Role\RoleInterface $role
+ * @param \Zend\Acl\Role\RoleInterface|string|array $parents
* @throws \Zend\Acl\Exception\InvalidArgumentException
* @return Registry Provides a fluent interface
*/
- public function add(Role $role, $parents = null)
+ public function add(Role\RoleInterface $role, $parents = null)
{
$roleId = $role->getRoleId();
@@ -77,13 +77,13 @@ public function add(Role $role, $parents = null)
}
foreach ($parents as $parent) {
try {
- if ($parent instanceof Role) {
+ if ($parent instanceof Role\RoleInterface) {
$roleParentId = $parent->getRoleId();
} else {
$roleParentId = $parent;
}
$roleParent = $this->get($roleParentId);
- } catch (Exception $e) {
+ } catch (\Exception $e) {
throw new Acl\Exception\InvalidArgumentException("Parent Role id '$roleParentId' does not exist", 0, $e);
}
$roleParents[$roleParentId] = $roleParent;
@@ -111,7 +111,7 @@ public function add(Role $role, $parents = null)
*/
public function get($role)
{
- if ($role instanceof Role) {
+ if ($role instanceof Role\RoleInterface) {
$roleId = $role->getRoleId();
} else {
$roleId = (string) $role;
@@ -134,7 +134,7 @@ public function get($role)
*/
public function has($role)
{
- if ($role instanceof Role) {
+ if ($role instanceof Role\RoleInterface) {
$roleId = $role->getRoleId();
} else {
$roleId = (string) $role;
@@ -154,7 +154,7 @@ public function has($role)
* If the Role does not have any parents, then an empty array is returned.
*
* @uses Zend\Acl\Role\Registry::get()
- * @param \Zend\Acl\Role|string $role
+ * @param \Zend\Acl\Role\RoleInterface|string $role
* @return array
*/
public function getParents($role)
@@ -173,9 +173,9 @@ public function getParents($role)
* through the entire inheritance DAG to determine whether $role
* inherits from $inherit through its ancestor Roles.
*
- * @param \Zend\Acl\Role|string $role
- * @param \Zend\Acl\Role|string $inherit
- * @param boolean $onlyParents
+ * @param \Zend\Acl\Role\RoleInterface|string $role
+ * @param \Zend\Acl\Role\RoleInterface|string $inherit
+ * @param boolean $onlyParents
* @throws \Zend\Acl\Exception\InvalidArgumentException
* @return boolean
*/
@@ -208,7 +208,7 @@ public function inherits($role, $inherit, $onlyParents = false)
*
* The $role parameter can either be a Role or a Role identifier.
*
- * @param \Zend\Acl\Role|string $role
+ * @param \Zend\Acl\Role\RoleInterface|string $role
* @throws \Zend\Acl\Exception\InvalidArgumentException
* @return Registry Provides a fluent interface
*/
@@ -18,15 +18,15 @@
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
-namespace Zend\Acl;
+namespace Zend\Acl\Role;
/**
* @category Zend
* @package Zend_Acl
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
-interface Role
+interface RoleInterface
{
/**
* Returns the string identifier of the Role
View
@@ -75,7 +75,7 @@ public function testRoleAddAndGetOneByString()
{
$role = $this->_acl->addRole('area')
->getRole('area');
- $this->assertInstanceOf('Zend\Acl\Role', $role);
+ $this->assertInstanceOf('Zend\Acl\Role\RoleInterface', $role);
$this->assertEquals('area', $role->getRoleId());
}
@@ -263,7 +263,7 @@ public function testResourceAddAndGetOneByString()
{
$resource = $this->_acl->addResource('area')
->getResource('area');
- $this->assertInstanceOf('Zend\Acl\Resource', $resource);
+ $this->assertInstanceOf('Zend\Acl\Resource\ResourceInterface', $resource);
$this->assertEquals('area', $resource->getResourceId());
}
@@ -302,7 +302,7 @@ public function testResourceRemoveOne()
*/
public function testResourceRemoveOneNonExistent()
{
- $this->setExpectedException('Zend\Acl\Exception', 'not found');
+ $this->setExpectedException('Zend\Acl\Exception\ExceptionInterface', 'not found');
$this->_acl->removeResource('nonexistent');
}
@@ -341,14 +341,14 @@ public function testResourceInheritsNonExistent()
$this->_acl->addResource($resourceArea);
try {
$this->_acl->inheritsResource('nonexistent', $resourceArea);
- $this->fail('Expected Zend\Acl\Exception not thrown upon specifying a non-existent child Resource');
- } catch (Acl\Exception $e) {
+ $this->fail('Expected Zend\Acl\Exception\ExceptionInterface not thrown upon specifying a non-existent child Resource');
+ } catch (Acl\Exception\ExceptionInterface $e) {
$this->assertContains('not found', $e->getMessage());
}
try {
$this->_acl->inheritsResource($resourceArea, 'nonexistent');
- $this->fail('Expected Zend\Acl\Exception not thrown upon specifying a non-existent parent Resource');
- } catch (Acl\Exception $e) {
+ $this->fail('Expected Zend\Acl\Exception\ExceptionInterface not thrown upon specifying a non-existent parent Resource');
+ } catch (Acl\Exception\ExceptionInterface $e) {
$this->assertContains('not found', $e->getMessage());
}
}
@@ -383,7 +383,7 @@ public function testResourceInherits()
*/
public function testResourceDuplicate()
{
- $this->setExpectedException('Zend\Acl\Exception', 'already exists');
+ $this->setExpectedException('Zend\Acl\Exception\ExceptionInterface', 'already exists');
$resourceArea = new Resource\GenericResource('area');
$this->_acl->addResource($resourceArea)
->addResource($resourceArea);
@@ -396,7 +396,7 @@ public function testResourceDuplicate()
*/
public function testResourceDuplicateId()
{
- $this->setExpectedException('Zend\Acl\Exception', 'already exists');
+ $this->setExpectedException('Zend\Acl\Exception\ExceptionInterface', 'already exists');
$resourceArea1 = new Resource\GenericResource('area');
$resourceArea2 = new Resource\GenericResource('area');
$this->_acl->addResource($resourceArea1)
@@ -412,13 +412,13 @@ public function testIsAllowedNonExistent()
{
try {
$this->_acl->isAllowed('nonexistent');
- $this->fail('Expected Zend\Acl\Role\Exception not thrown upon non-existent Role');
+ $this->fail('Expected Zend\Acl\Role\Exception\ExceptionInterface not thrown upon non-existent Role');
} catch (Acl\Exception\InvalidArgumentException $e) {
$this->assertContains('not found', $e->getMessage());
}
try {
$this->_acl->isAllowed(null, 'nonexistent');
- $this->fail('Expected Zend\Acl\Exception not thrown upon non-existent Resource');
+ $this->fail('Expected Zend\Acl\Exception\ExceptionInterface not thrown upon non-existent Resource');
} catch (Acl\Exception\InvalidArgumentException $e) {
$this->assertContains('not found', $e->getMessage());
}
@@ -821,7 +821,7 @@ public function testRulesResourceRemove()
try {
$this->_acl->isAllowed(null, 'area');
$this->fail('Expected Zend\Acl\Exception not thrown upon isAllowed() on non-existent Resource');
- } catch (Acl\Exception $e) {
+ } catch (Acl\Exception\ExceptionInterface $e) {
$this->assertContains('not found', $e->getMessage());
}
$this->_acl->addResource(new Resource\GenericResource('area'));
@@ -841,8 +841,8 @@ public function testRulesResourceRemoveAll()
$this->_acl->removeResourceAll();
try {
$this->_acl->isAllowed(null, 'area');
- $this->fail('Expected Zend\Acl\Exception not thrown upon isAllowed() on non-existent Resource');
- } catch (Acl\Exception $e) {
+ $this->fail('Expected Zend\Acl\Exception\ExceptionInterface not thrown upon isAllowed() on non-existent Resource');
+ } catch (Acl\Exception\ExceptionInterface $e) {
$this->assertContains('not found', $e->getMessage());
}
$this->_acl->addResource(new Resource\GenericResource('area'));
@@ -1052,28 +1052,28 @@ public function testAclInternalDFSMethodsBehaveProperly()
try {
$acl->roleDFSVisitAllPrivileges($someRole, $someResource, $nullReference);
$this->fail('Expected Zend\Acl\Exception not thrown');
- } catch (Acl\Exception $e) {
+ } catch (Acl\Exception\ExceptionInterface $e) {
$this->assertEquals('$dfs parameter may not be null', $e->getMessage());
}
try {
$acl->roleDFSOnePrivilege($someRole, $someResource, null);
$this->fail('Expected Zend\Acl\Exception not thrown');
- } catch (Acl\Exception $e) {
+ } catch (Acl\Exception\ExceptionInterface $e) {
$this->assertEquals('$privilege parameter may not be null', $e->getMessage());
}
try {
$acl->roleDFSVisitOnePrivilege($someRole, $someResource, null);
$this->fail('Expected Zend\Acl\Exception not thrown');
- } catch (Acl\Exception $e) {
+ } catch (Acl\Exception\ExceptionInterface $e) {
$this->assertEquals('$privilege parameter may not be null', $e->getMessage());
}
try {
$acl->roleDFSVisitOnePrivilege($someRole, $someResource, 'somePrivilege', $nullReference);
$this->fail('Expected Zend\\Acl\\Exception not thrown');
- } catch (Acl\Exception $e) {
+ } catch (Acl\Exception\ExceptionInterface $e) {
$this->assertEquals('$dfs parameter may not be null', $e->getMessage());
}
}
@@ -6,7 +6,7 @@
Zend\Acl;
class AssertionZF7973 implements Assertion {
- public function assert(Acl\Acl $acl, Acl\Role $role = null, Acl\Resource $resource = null, $privilege = null)
+ public function assert(Acl\Acl $acl, Acl\Role\RoleInterface $role = null, Acl\Resource\ResourceInterface $resource = null, $privilege = null)
{
if($privilege != 'privilege') {
return false;
@@ -5,19 +5,19 @@
class ExtendedAclZF2234 extends Acl\Acl
{
- public function roleDFSVisitAllPrivileges(Acl\Role $role, Acl\Resource $resource = null,
+ public function roleDFSVisitAllPrivileges(Acl\Role\RoleInterface $role, Acl\Resource\ResourceInterface $resource = null,
&$dfs = null)
{
return $this->_roleDFSVisitAllPrivileges($role, $resource, $dfs);
}
- public function roleDFSOnePrivilege(Acl\Role $role, Acl\Resource $resource = null,
+ public function roleDFSOnePrivilege(Acl\Role\RoleInterface $role, Acl\Resource\ResourceInterface $resource = null,
$privilege = null)
{
return $this->_roleDFSOnePrivilege($role, $resource, $privilege);
}
- public function roleDFSVisitOnePrivilege(Acl\Role $role, Acl\Resource $resource = null,
+ public function roleDFSVisitOnePrivilege(Acl\Role\RoleInterface $role, Acl\Resource\ResourceInterface $resource = null,
$privilege = null, &$dfs = null)
{
return $this->_roleDFSVisitOnePrivilege($role, $resource, $privilege, $dfs);
@@ -13,7 +13,7 @@ public function __construct($returnValue)
$this->_returnValue = (bool) $returnValue;
}
- public function assert(Acl\Acl $acl, Acl\Role $role = null, Acl\Resource $resource = null,
+ public function assert(Acl\Acl $acl, Acl\Role\RoleInterface $role = null, Acl\Resource\ResourceInterface $resource = null,
$privilege = null)
{
return $this->_returnValue;
@@ -4,7 +4,7 @@
use Zend\Acl\Resource;
-class BlogPost implements Resource
+class BlogPost implements Resource\ResourceInterface
{
public $owner = null;
public function getResourceId()
Oops, something went wrong.

0 comments on commit 12c8e7d

Please sign in to comment.