Role: Add param $cascadeUpwards also to public method grant()

This commit is contained in:
Johannes Meyer 2021-03-24 09:10:06 +01:00
parent c203ffdd79
commit ab90b3e0a1

View File

@ -253,19 +253,20 @@ class Role
* *
* @param string $permission * @param string $permission
* @param bool $ignoreParent Only evaluate the role's own permissions * @param bool $ignoreParent Only evaluate the role's own permissions
* @param bool $cascadeUpwards `false` if `foo/bar/*` and `foo/bar/raboof` should not match `foo/*`
* *
* @return bool * @return bool
*/ */
public function grants($permission, $ignoreParent = false) public function grants($permission, $ignoreParent = false, $cascadeUpwards = true)
{ {
foreach ($this->permissions as $grantedPermission) { foreach ($this->permissions as $grantedPermission) {
if ($this->match($grantedPermission, $permission)) { if ($this->match($grantedPermission, $permission, $cascadeUpwards)) {
return true; return true;
} }
} }
if (! $ignoreParent && $this->getParent() !== null) { if (! $ignoreParent && $this->getParent() !== null) {
return $this->getParent()->grants($permission); return $this->getParent()->grants($permission, false, $cascadeUpwards);
} }
return false; return false;