Files
breadcrumb-the-shire/lib/Service/Import/Profile/DepartmentImportGateway.php

62 lines
1.7 KiB
PHP
Raw Normal View History

2026-02-23 12:58:19 +01:00
<?php
namespace MintyPHP\Service\Import\Profile;
use MintyPHP\Repository\Org\DepartmentRepository;
use MintyPHP\Repository\Tenant\TenantRepository;
use MintyPHP\Service\Org\DepartmentService;
class DepartmentImportGateway
{
public function __construct(
2026-03-04 15:56:58 +01:00
private readonly DepartmentRepository $departmentRepository,
private readonly TenantRepository $tenantRepository,
private readonly DepartmentService $departmentService
2026-02-23 12:58:19 +01:00
) {
}
public function findTenantByUuid(string $uuid): ?array
{
return $this->tenantRepository()->findByUuid($uuid);
}
public function findTenantById(int $id): ?array
{
return $this->tenantRepository()->find($id);
}
public function existsDepartmentCode(string $code): bool
{
return $this->departmentRepository()->existsByCode($code);
}
public function existsDepartmentByTenantAndDescription(int $tenantId, string $description): bool
{
return $this->departmentRepository()->existsByTenantAndDescription($tenantId, $description);
}
/**
* @param array<string, mixed> $input
* @return array<string, mixed>
*/
public function createDepartmentFromAdmin(array $input, int $currentUserId): array
{
return $this->departmentService()->createFromAdmin($input, $currentUserId);
}
private function departmentRepository(): DepartmentRepository
{
2026-03-04 15:56:58 +01:00
return $this->departmentRepository;
2026-02-23 12:58:19 +01:00
}
private function tenantRepository(): TenantRepository
{
2026-03-04 15:56:58 +01:00
return $this->tenantRepository;
2026-02-23 12:58:19 +01:00
}
private function departmentService(): DepartmentService
{
2026-03-04 15:56:58 +01:00
return $this->departmentService;
2026-02-23 12:58:19 +01:00
}
}