/** * @return array */ public function getParents() { if (!$this->_parents) { $item = $this->getItem($this->name, $this->type); $roles = $this->getRoles(); $perms = $this->getPerms(); $childrens = $this->getChildrensNames(); if (!empty($roles)) { foreach ($roles as $role) { if ($role->name != $this->name && !in_array($role->name, $childrens)) { if ($this->_authMan->hasChild($role, $item)) { $this->_parents[] = $role; $this->_parents_names[] = $role->name; } } } } if (!empty($perms)) { foreach ($perms as $perm) { if ($perm->name != $this->name && !in_array($perm->name, $childrens)) { if ($this->_authMan->hasChild($perm, $item)) { $this->_parents[] = $perm; $this->_parents_names[] = $perm->name; } } } } } return $this->_parents; }