resolver = $resolver; $this->perm_structure = $resolver->getPermissionStructure(); } /** * Checks if the passed value is valid. * * @param mixed $value The value that should be validated * @param Constraint $constraint The constraint for the validation */ public function validate($value, Constraint $constraint) { if (!$constraint instanceof ValidPermission) { throw new UnexpectedTypeException($constraint, ValidPermission::class); } /** @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); } } } } } }