26 #require_once 'Zend/Acl/Role/Interface.php'; 71 #require_once 'Zend/Acl/Role/Registry/Exception.php'; 75 $roleParents = array();
77 if (
null !== $parents) {
78 if (!is_array($parents)) {
79 $parents = array($parents);
84 #require_once 'Zend/Acl/Role/Registry/Exception.php'; 85 foreach ($parents as $parent) {
88 $roleParentId = $parent->getRoleId();
90 $roleParentId = $parent;
92 $roleParent = $this->
get($roleParentId);
96 $roleParents[$roleParentId] = $roleParent;
97 $this->_roles[$roleParentId][
'children'][
$roleId] = $role;
101 $this->_roles[
$roleId] = array(
103 'parents' => $roleParents,
104 'children' => array()
119 public function get($role)
127 if (!$this->
has($role)) {
131 #require_once 'Zend/Acl/Role/Registry/Exception.php'; 135 return $this->_roles[
$roleId][
'instance'];
146 public function has($role)
154 return isset($this->_roles[
$roleId]);
173 $roleId = $this->
get($role)->getRoleId();
175 return $this->_roles[
$roleId][
'parents'];
193 public function inherits($role, $inherit, $onlyParents =
false)
198 #require_once 'Zend/Acl/Role/Registry/Exception.php'; 200 $roleId = $this->
get($role)->getRoleId();
201 $inheritId = $this->
get($inherit)->getRoleId();
206 $inherits = isset($this->_roles[
$roleId][
'parents'][$inheritId]);
208 if ($inherits || $onlyParents) {
212 foreach ($this->_roles[
$roleId][
'parents'] as $parentId => $parent) {
213 if ($this->
inherits($parentId, $inheritId)) {
230 public function remove($role)
235 #require_once 'Zend/Acl/Role/Registry/Exception.php'; 237 $roleId = $this->
get($role)->getRoleId();
242 foreach ($this->_roles[
$roleId][
'children'] as $childId => $child) {
243 unset($this->_roles[$childId][
'parents'][
$roleId]);
245 foreach ($this->_roles[
$roleId][
'parents'] as $parentId => $parent) {
246 unset($this->_roles[$parentId][
'children'][
$roleId]);
261 $this->_roles = array();
inherits($role, $inherit, $onlyParents=false)
add(Zend_Acl_Role_Interface $role, $parents=null)