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;
2026-03-05 08:26:51 +01:00
use MintyPHP\Repository\Org\DepartmentRepositoryInterface;
use MintyPHP\Repository\Tenant\TenantRepositoryInterface;
2026-02-23 12:58:19 +01:00
use MintyPHP\Service\Org\DepartmentService;
class DepartmentImportGateway
{
public function __construct(
2026-03-05 08:26:51 +01:00
private readonly DepartmentRepositoryInterface $departmentRepository,
private readonly TenantRepositoryInterface $tenantRepository,
2026-03-04 15:56:58 +01:00
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);
}
2026-03-05 08:26:51 +01:00
private function departmentRepository(): DepartmentRepositoryInterface
2026-02-23 12:58:19 +01:00
{
2026-03-04 15:56:58 +01:00
return $this->departmentRepository;
2026-02-23 12:58:19 +01:00
}
2026-03-05 08:26:51 +01:00
private function tenantRepository(): TenantRepositoryInterface
2026-02-23 12:58:19 +01:00
{
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
}
}