PermissibleBase: simplify diff calculation

This commit is contained in:
Dylan K. Taylor 2020-12-02 11:29:45 +00:00
parent 506e76917e
commit c5e12bb11f

View File

@ -162,13 +162,11 @@ class PermissibleBase implements Permissible{
if(!isset($oldPermissions[$name])){ if(!isset($oldPermissions[$name])){
$diff[$name] = false; $diff[$name] = false;
}elseif($oldPermissions[$name]->getValue() !== $permissionAttachmentInfo->getValue()){ }elseif($oldPermissions[$name]->getValue() !== $permissionAttachmentInfo->getValue()){
//permission was previously unset OR the value of the permission changed continue;
//we don't care who assigned the permission, only that the result is different
$diff[$name] = $oldPermissions[$name]->getValue();
} }
unset($oldPermissions[$name]); unset($oldPermissions[$name]);
} }
//oldPermissions now only contains permissions that are no longer set after recalculation //oldPermissions now only contains permissions that changed or are no longer set
foreach($oldPermissions as $permissionAttachmentInfo){ foreach($oldPermissions as $permissionAttachmentInfo){
$diff[$permissionAttachmentInfo->getPermission()] = $permissionAttachmentInfo->getValue(); $diff[$permissionAttachmentInfo->getPermission()] = $permissionAttachmentInfo->getValue();
} }