instances added god may help

This commit is contained in:
2026-02-23 12:58:19 +01:00
parent 25370a1a55
commit 99db252f60
290 changed files with 9858 additions and 4914 deletions

View File

@@ -2,12 +2,12 @@
namespace MintyPHP\Service\Import\Profile;
use MintyPHP\Repository\Org\DepartmentRepository;
use MintyPHP\Repository\Tenant\TenantRepository;
use MintyPHP\Service\Org\DepartmentService;
class DepartmentImportProfile implements ImportProfileInterface
{
public function __construct(private readonly DepartmentImportGateway $gateway)
{
}
public function key(): string
{
return 'departments';
@@ -81,7 +81,7 @@ class DepartmentImportProfile implements ImportProfileInterface
if (!$this->isUuid($tenantRaw)) {
$errors[] = ['code' => 'invalid_tenant_uuid'];
} else {
$tenant = TenantRepository::findByUuid($tenantRaw);
$tenant = $this->gateway->findTenantByUuid($tenantRaw);
if (!$tenant || (string) ($tenant['status'] ?? '') !== 'active') {
$errors[] = ['code' => 'tenant_not_found'];
}
@@ -91,7 +91,7 @@ class DepartmentImportProfile implements ImportProfileInterface
if (!$tenant) {
$defaultTenantId = (int) ($context['default_tenant_id'] ?? 0);
if ($defaultTenantId > 0) {
$defaultTenant = TenantRepository::find($defaultTenantId);
$defaultTenant = $this->gateway->findTenantById($defaultTenantId);
if ($defaultTenant && (string) ($defaultTenant['status'] ?? '') === 'active') {
$tenant = $defaultTenant;
}
@@ -139,7 +139,7 @@ class DepartmentImportProfile implements ImportProfileInterface
return ['status' => 'skipped', 'code' => 'department_exists'];
}
$result = DepartmentService::createFromAdmin([
$result = $this->gateway->createDepartmentFromAdmin([
'description' => (string) ($normalized['description'] ?? ''),
'tenant_id' => (int) ($normalized['tenant_id'] ?? 0),
'code' => (string) ($normalized['code'] ?? ''),
@@ -190,7 +190,7 @@ class DepartmentImportProfile implements ImportProfileInterface
if ($code === '') {
return false;
}
return DepartmentRepository::existsByCode($code);
return $this->gateway->existsDepartmentCode($code);
}
private function departmentExists(array $normalized): bool
@@ -200,7 +200,7 @@ class DepartmentImportProfile implements ImportProfileInterface
if ($tenantId <= 0 || $description === '') {
return false;
}
return DepartmentRepository::existsByTenantAndDescription($tenantId, $description);
return $this->gateway->existsDepartmentByTenantAndDescription($tenantId, $description);
}
private function parseActive(string $value): ?int