Files
breadcrumb-the-shire/lib/Service/User/UserDirectoryGateway.php

81 lines
2.2 KiB
PHP
Raw Normal View History

2026-02-23 12:58:19 +01:00
<?php
namespace MintyPHP\Service\User;
2026-03-05 08:26:51 +01:00
use MintyPHP\Repository\Access\RoleRepositoryInterface;
use MintyPHP\Repository\Org\DepartmentRepositoryInterface;
use MintyPHP\Repository\Tenant\TenantRepositoryInterface;
2026-02-23 12:58:19 +01:00
class UserDirectoryGateway
{
2026-03-04 15:56:58 +01:00
public function __construct(
private readonly UserRepositoryFactory $userRepositoryFactory
) {
}
2026-02-23 12:58:19 +01:00
public function listTenantIds(): array
{
2026-03-04 15:56:58 +01:00
return $this->tenantRepository()->listIds();
2026-02-23 12:58:19 +01:00
}
public function listTenantsByIds(array $tenantIds): array
{
2026-03-04 15:56:58 +01:00
return $this->tenantRepository()->listByIds($tenantIds);
2026-02-23 12:58:19 +01:00
}
public function findTenant(int $tenantId): ?array
{
2026-03-04 15:56:58 +01:00
return $this->tenantRepository()->find($tenantId);
}
public function findTenantByUuid(string $tenantUuid): ?array
{
return $this->tenantRepository()->findByUuid($tenantUuid);
2026-02-23 12:58:19 +01:00
}
public function listActiveTenantIdsByIds(array $tenantIds): array
{
2026-03-04 15:56:58 +01:00
return $this->tenantRepository()->listActiveIdsByIds($tenantIds);
2026-02-23 12:58:19 +01:00
}
public function listActiveRoleIds(): array
{
2026-03-04 15:56:58 +01:00
return $this->roleRepository()->listActiveIds();
2026-02-23 12:58:19 +01:00
}
public function listRolesByIds(array $roleIds): array
{
2026-03-04 15:56:58 +01:00
return $this->roleRepository()->listByIds($roleIds);
2026-02-23 12:58:19 +01:00
}
public function listDepartmentsByIds(array $departmentIds, bool $includeInactive = true): array
{
2026-03-04 15:56:58 +01:00
return $this->departmentRepository()->listByIds($departmentIds, $includeInactive);
2026-02-23 12:58:19 +01:00
}
public function listActiveDepartmentIdsByTenantIds(array $tenantIds): array
{
2026-03-04 15:56:58 +01:00
return $this->departmentRepository()->listActiveIdsByTenantIds($tenantIds);
2026-02-23 12:58:19 +01:00
}
public function listDepartmentsByTenantIds(array $tenantIds): array
{
2026-03-04 15:56:58 +01:00
return $this->departmentRepository()->listByTenantIds($tenantIds);
}
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
}
}