Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Add RoleInterface #3546

Merged
merged 1 commit into from

3 participants

@spiffyjr

No description provided.

@spiffyjr

Not quite sure why the diff shows up so odd.

@Maks3w
Collaborator

Look a change in line endings. Be sure that are Linux line endings (\n)

@spiffyjr

Ugh, temporarily working in Windows. Sure is annoying...

@spiffyjr

Updated.

@spiffyjr

... and rebased!

@ezimuel ezimuel merged commit c58435b into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 24, 2013
  1. @spiffyjr

    Add RoleInterface

    spiffyjr authored
This page is out of date. Refresh to see the latest.
View
20 library/Zend/Permissions/Rbac/AbstractRole.php
@@ -11,10 +11,10 @@
use RecursiveIteratorIterator;
-abstract class AbstractRole extends AbstractIterator
+abstract class AbstractRole extends AbstractIterator implements RoleInterface
{
/**
- * @var null|AbstractRole
+ * @var null|RoleInterface
*/
protected $parent;
@@ -42,7 +42,7 @@ public function getName()
* Add permission to the role.
*
* @param $name
- * @return AbstractRole
+ * @return RoleInterface
*/
public function addPermission($name)
{
@@ -65,7 +65,7 @@ public function hasPermission($name)
$it = new RecursiveIteratorIterator($this, RecursiveIteratorIterator::CHILD_FIRST);
foreach ($it as $leaf) {
- /** @var AbstractRole $leaf */
+ /** @var RoleInterface $leaf */
if ($leaf->hasPermission($name)) {
return true;
}
@@ -77,7 +77,7 @@ public function hasPermission($name)
/**
* Add a child.
*
- * @param AbstractRole|string $child
+ * @param RoleInterface|string $child
* @return Role
*/
public function addChild($child)
@@ -85,9 +85,9 @@ public function addChild($child)
if (is_string($child)) {
$child = new Role($child);
}
- if (!$child instanceof AbstractRole) {
+ if (!$child instanceof RoleInterface) {
throw new Exception\InvalidArgumentException(
- 'Child must be a string or instance of Zend\Permissions\Rbac\AbstractRole'
+ 'Child must be a string or implement Zend\Permissions\Rbac\RoleInterface'
);
}
@@ -98,8 +98,8 @@ public function addChild($child)
}
/**
- * @param AbstractRole $parent
- * @return AbstractRole
+ * @param RoleInterface $parent
+ * @return RoleInterface
*/
public function setParent($parent)
{
@@ -109,7 +109,7 @@ public function setParent($parent)
}
/**
- * @return null|AbstractRole
+ * @return null|RoleInterface
*/
public function getParent()
{
View
18 library/Zend/Permissions/Rbac/Rbac.php
@@ -43,8 +43,8 @@ public function getCreateMissingRoles()
/**
* Add a child.
*
- * @param string|AbstractRole $child
- * @return AbstractRole
+ * @param string|RoleInterface $child
+ * @return RoleInterface
* @throws Exception\InvalidArgumentException
*/
public function addRole($child, $parents = null)
@@ -52,9 +52,9 @@ public function addRole($child, $parents = null)
if (is_string($child)) {
$child = new Role($child);
}
- if (!$child instanceof AbstractRole) {
+ if (!$child instanceof RoleInterface) {
throw new Exception\InvalidArgumentException(
- 'Child must be a string or instance of Zend\Permissions\Rbac\AbstractRole'
+ 'Child must be a string or implement Zend\Permissions\Rbac\RoleInterface'
);
}
@@ -78,7 +78,7 @@ public function addRole($child, $parents = null)
/**
* Is a child with $name registered?
*
- * @param \Zend\Permissions\Rbac\AbstractRole|string $objectOrName
+ * @param \Zend\Permissions\Rbac\RoleInterface|string $objectOrName
* @return bool
*/
public function hasRole($objectOrName)
@@ -95,15 +95,15 @@ public function hasRole($objectOrName)
/**
* Get a child.
*
- * @param \Zend\Permissions\Rbac\AbstractRole|string $objectOrName
- * @return AbstractRole
+ * @param \Zend\Permissions\Rbac\RoleInterface|string $objectOrName
+ * @return RoleInterface
* @throws Exception\InvalidArgumentException
*/
public function getRole($objectOrName)
{
- if (!is_string($objectOrName) && !$objectOrName instanceof AbstractRole) {
+ if (!is_string($objectOrName) && !$objectOrName instanceof RoleInterface) {
throw new Exception\InvalidArgumentException(
- 'Expected string or instance of \Zend\Permissions\Rbac\AbstractRole'
+ 'Expected string or implement \Zend\Permissions\Rbac\RoleInterface'
);
}
View
55 library/Zend/Permissions/Rbac/RoleInterface.php
@@ -0,0 +1,55 @@
+<?php
+/**
+ * Zend Framework (http://framework.zend.com/)
+ *
+ * @link http://github.com/zendframework/zf2 for the canonical source repository
+ * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+
+namespace Zend\Permissions\Rbac;
+
+interface RoleInterface
+{
+ /**
+ * Get the name of the role.
+ *
+ * @return string
+ */
+ public function getName();
+
+ /**
+ * Add permission to the role.
+ *
+ * @param $name
+ * @return RoleInterface
+ */
+ public function addPermission($name);
+
+ /**
+ * Checks if a permission exists for this role or any child roles.
+ *
+ * @param string $name
+ * @return bool
+ */
+ public function hasPermission($name);
+
+ /**
+ * Add a child.
+ *
+ * @param RoleInterface|string $child
+ * @return Role
+ */
+ public function addChild($child);
+
+ /**
+ * @param RoleInterface $parent
+ * @return RoleInterface
+ */
+ public function setParent($parent);
+
+ /**
+ * @return null|RoleInterface
+ */
+ public function getParent();
+}
Something went wrong with that request. Please try again.