refactor(arch): enforce gateway compliance and remove service-wrapping gateways
This commit is contained in:
@@ -4,58 +4,32 @@ namespace MintyPHP\Service\Import\Profile;
|
||||
|
||||
use MintyPHP\Repository\Org\DepartmentRepositoryInterface;
|
||||
use MintyPHP\Repository\Tenant\TenantRepositoryInterface;
|
||||
use MintyPHP\Service\Org\DepartmentService;
|
||||
|
||||
class DepartmentImportGateway
|
||||
{
|
||||
public function __construct(
|
||||
private readonly DepartmentRepositoryInterface $departmentRepository,
|
||||
private readonly TenantRepositoryInterface $tenantRepository,
|
||||
private readonly DepartmentService $departmentService
|
||||
private readonly TenantRepositoryInterface $tenantRepository
|
||||
) {
|
||||
}
|
||||
|
||||
public function findTenantByUuid(string $uuid): ?array
|
||||
{
|
||||
return $this->tenantRepository()->findByUuid($uuid);
|
||||
return $this->tenantRepository->findByUuid($uuid);
|
||||
}
|
||||
|
||||
public function findTenantById(int $id): ?array
|
||||
{
|
||||
return $this->tenantRepository()->find($id);
|
||||
return $this->tenantRepository->find($id);
|
||||
}
|
||||
|
||||
public function existsDepartmentCode(string $code): bool
|
||||
{
|
||||
return $this->departmentRepository()->existsByCode($code);
|
||||
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(): DepartmentRepositoryInterface
|
||||
{
|
||||
return $this->departmentRepository;
|
||||
}
|
||||
|
||||
private function tenantRepository(): TenantRepositoryInterface
|
||||
{
|
||||
return $this->tenantRepository;
|
||||
}
|
||||
|
||||
private function departmentService(): DepartmentService
|
||||
{
|
||||
return $this->departmentService;
|
||||
return $this->departmentRepository->existsByTenantAndDescription($tenantId, $description);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user