ZoneOwnershipGuard
class ZoneOwnershipGuard (View source)
The last-owner rule: a zone keeps at least one owner of a kind the ownership mode allows. Every writer removes owners through here, so the check and the delete share one transaction and two concurrent removals cannot both pass.
Methods
No description
Removes a user owner, deciding and deleting inside one transaction.
Removes a group owner, deciding and deleting inside one transaction.
Whether new owners or groups would be granted nothing on this zone id, because two zones share it (see ZoneOwnershipRepositoryInterface::isSharedZoneId()).
Null when the user may be removed; a refusal otherwise. A user who is not an owner is never refused, so the caller's own not-found path still runs.
Null when the group may be removed; a refusal otherwise. A group that does not own the zone is never refused.
Zones that would be left without an allowed owner if the group were deleted, because deleting it drops its zones_groups rows.
Deletes a group, deciding and writing under the same locks the single-zone removals take, so a concurrent removal of the other owner cannot slip in between the check and the delete and leave a zone with nobody.
Details
__construct(ZoneOwnershipRepositoryInterface $zoneRepository, ZoneGroupRepositoryInterface $zoneGroupRepository, ZoneOwnershipModeService $ownershipMode, TransactionInterface $transaction)
No description
ZoneOwnershipRefusal|bool
removeUserOwner(int $zoneId, int $userId)
Removes a user owner, deciding and deleting inside one transaction.
Returns the refusal when the rule forbids it, otherwise whether a row went.
ZoneOwnershipRefusal|bool
removeGroup(int $zoneId, int $groupId)
Removes a group owner, deciding and deleting inside one transaction.
Returns the refusal when the rule forbids it, otherwise whether a row went.
bool
refusesNewGrants(int $zoneId)
Whether new owners or groups would be granted nothing on this zone id, because two zones share it (see ZoneOwnershipRepositoryInterface::isSharedZoneId()).
ZoneOwnershipRefusal|null
refuseUserOwnerRemoval(int $zoneId, int $userId)
Null when the user may be removed; a refusal otherwise. A user who is not an owner is never refused, so the caller's own not-found path still runs.
ZoneOwnershipRefusal|null
refuseGroupRemoval(int $zoneId, int $groupId)
Null when the group may be removed; a refusal otherwise. A group that does not own the zone is never refused.
array
zonesOrphanedByGroupDeletion(int $groupId)
Zones that would be left without an allowed owner if the group were deleted, because deleting it drops its zones_groups rows.
array|bool
deleteGroup(int $groupId, callable $delete)
Deletes a group, deciding and writing under the same locks the single-zone removals take, so a concurrent removal of the other owner cannot slip in between the check and the delete and leave a zone with nobody.