Allow to change all permissions at once via the console command.

This commit is contained in:
Jan Böhmer 2022-11-05 23:20:26 +01:00
parent 3fbc72600f
commit a30b67e328
3 changed files with 57 additions and 36 deletions

View file

@ -56,7 +56,6 @@ class ValidPermissionValidator extends ConstraintValidator
public function __construct(PermissionResolver $resolver)
{
$this->resolver = $resolver;
$this->perm_structure = $resolver->getPermissionStructure();
}
/**
@ -74,17 +73,6 @@ class ValidPermissionValidator extends ConstraintValidator
/** @var HasPermissionsInterface $perm_holder */
$perm_holder = $this->context->getObject();
//Check for each permission and operation, for an alsoSet attribute
foreach ($this->perm_structure['perms'] as $perm_key => $permission) {
foreach ($permission['operations'] as $op_key => $op) {
if (!empty($op['alsoSet']) &&
true === $this->resolver->dontInherit($perm_holder, $perm_key, $op_key)) {
//Set every op listed in also Set
foreach ($op['alsoSet'] as $set_also) {
$this->resolver->setPermission($perm_holder, $perm_key, $set_also, true);
}
}
}
}
$this->resolver->ensureCorrectSetOperations($perm_holder);
}
}