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

80 lines
2.2 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\Access\RoleRepositoryInterface;
use MintyPHP\Repository\Org\DepartmentRepositoryInterface;
use MintyPHP\Repository\Tenant\TenantRepositoryInterface;
use MintyPHP\Repository\User\UserReadRepositoryInterface;
2026-02-23 12:58:19 +01:00
use MintyPHP\Service\User\UserAccountService;
2026-03-04 15:56:58 +01:00
use MintyPHP\Service\User\UserRepositoryFactory;
2026-02-23 12:58:19 +01:00
class UserImportGateway
{
public function __construct(
2026-03-05 08:26:51 +01:00
private readonly UserReadRepositoryInterface $userReadRepository,
2026-03-04 15:56:58 +01:00
private readonly UserAccountService $userAccountService,
private readonly UserRepositoryFactory $userRepositoryFactory
2026-02-23 12:58:19 +01:00
) {
}
public function findUserByEmail(string $email): ?array
{
return $this->userReadRepository->findByEmail($email);
}
public function findTenantByUuid(string $uuid): ?array
{
2026-03-04 15:56:58 +01:00
return $this->tenantRepository()->findByUuid($uuid);
2026-02-23 12:58:19 +01:00
}
public function findTenantById(int $id): ?array
{
2026-03-04 15:56:58 +01:00
return $this->tenantRepository()->find($id);
2026-02-23 12:58:19 +01:00
}
public function findRoleByUuid(string $uuid): ?array
{
2026-03-04 15:56:58 +01:00
return $this->roleRepository()->findByUuid($uuid);
2026-02-23 12:58:19 +01:00
}
public function findRoleById(int $id): ?array
{
2026-03-04 15:56:58 +01:00
return $this->roleRepository()->find($id);
2026-02-23 12:58:19 +01:00
}
public function findDepartmentByUuid(string $uuid): ?array
{
2026-03-04 15:56:58 +01:00
return $this->departmentRepository()->findByUuid($uuid);
2026-02-23 12:58:19 +01:00
}
public function findDepartmentById(int $id): ?array
{
2026-03-04 15:56:58 +01:00
return $this->departmentRepository()->find($id);
2026-02-23 12:58:19 +01:00
}
/**
* @param array<string, mixed> $input
* @return array<string, mixed>
*/
public function createUserFromAdmin(array $input, int $currentUserId): array
{
return $this->userAccountService->createFromAdmin($input, $currentUserId);
}
2026-03-04 15:56:58 +01:00
2026-03-05 08:26:51 +01:00
private function tenantRepository(): TenantRepositoryInterface
2026-03-04 15:56:58 +01:00
{
return $this->userRepositoryFactory->createTenantRepository();
}
2026-03-05 08:26:51 +01:00
private function roleRepository(): RoleRepositoryInterface
2026-03-04 15:56:58 +01:00
{
return $this->userRepositoryFactory->createRoleRepository();
}
2026-03-05 08:26:51 +01:00
private function departmentRepository(): DepartmentRepositoryInterface
2026-03-04 15:56:58 +01:00
{
return $this->userRepositoryFactory->createDepartmentRepository();
}
2026-02-23 12:58:19 +01:00
}