refactor(support): consolidate remaining ID normalization via toIntIds()
Extends the toIntIds() rollout to service and repository layers: - Drops a third private duplicate (UserCustomFieldValueService::normalizeTenantIds) - Collapses the two-line intval+filter pattern inside UserAssignmentService, UserAuthorizationPolicy, SsoUserLinkService, DepartmentService, and UserCustomFieldValueService - Replaces inline patterns in 4 repositories (RolePermissionRepository, RoleAssignableRoleRepository, UserWriteRepository, DepartmentRepository, UserCustomFieldValueRepository, UserCustomFieldValueOptionRepository) - Simplifies the notifications sanitizeTenantIds trait body Tenant-area files deliberately untouched per parallel ongoing work on the tenant-logo refactor. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -27,8 +27,7 @@ class UserCustomFieldValueRepository implements UserCustomFieldValueRepositoryIn
|
||||
if ($userId <= 0) {
|
||||
return [];
|
||||
}
|
||||
$definitionIds = array_values(array_unique(array_map('intval', $definitionIds)));
|
||||
$definitionIds = array_values(array_filter($definitionIds, static fn ($id) => $id > 0));
|
||||
$definitionIds = toIntIds($definitionIds);
|
||||
if (!$definitionIds) {
|
||||
return [];
|
||||
}
|
||||
@@ -85,8 +84,7 @@ class UserCustomFieldValueRepository implements UserCustomFieldValueRepositoryIn
|
||||
if ($userId <= 0) {
|
||||
return false;
|
||||
}
|
||||
$definitionIds = array_values(array_unique(array_map('intval', $definitionIds)));
|
||||
$definitionIds = array_values(array_filter($definitionIds, static fn ($id) => $id > 0));
|
||||
$definitionIds = toIntIds($definitionIds);
|
||||
if (!$definitionIds) {
|
||||
return true;
|
||||
}
|
||||
@@ -103,8 +101,7 @@ class UserCustomFieldValueRepository implements UserCustomFieldValueRepositoryIn
|
||||
if ($userId <= 0) {
|
||||
return false;
|
||||
}
|
||||
$tenantIds = array_values(array_unique(array_map('intval', $tenantIds)));
|
||||
$tenantIds = array_values(array_filter($tenantIds, static fn ($id) => $id > 0));
|
||||
$tenantIds = toIntIds($tenantIds);
|
||||
if (!$tenantIds) {
|
||||
$result = DB::delete('delete from user_custom_field_values where user_id = ?', (string) $userId);
|
||||
return $result !== false;
|
||||
|
||||
Reference in New Issue
Block a user