listen ansichten verbessert

This commit is contained in:
2026-03-05 11:17:42 +01:00
parent 4b31fc7664
commit c5f657c8c8
133 changed files with 2806 additions and 636 deletions

View File

@@ -565,7 +565,7 @@ class UserAccountService
$errors[] = t('Tenant not found');
} else {
$userTenantIds = $this->userAssignmentService->buildAssignmentsForUser($userId)['tenants'] ?? [];
$userTenantIds = array_map(static fn(array $t): int => (int) ($t['id'] ?? 0), $userTenantIds);
$userTenantIds = array_map(static fn (array $t): int => (int) ($t['id'] ?? 0), $userTenantIds);
$tenantId = (int) $tenant['id'];
if (!in_array($tenantId, $userTenantIds, true)) {
$errors[] = t('No access to this tenant');

View File

@@ -9,72 +9,59 @@ use MintyPHP\Repository\Tenant\TenantRepositoryInterface;
class UserDirectoryGateway
{
public function __construct(
private readonly UserRepositoryFactory $userRepositoryFactory
private readonly TenantRepositoryInterface $tenantRepository,
private readonly RoleRepositoryInterface $roleRepository,
private readonly DepartmentRepositoryInterface $departmentRepository,
) {
}
public function listTenantIds(): array
{
return $this->tenantRepository()->listIds();
return $this->tenantRepository->listIds();
}
public function listTenantsByIds(array $tenantIds): array
{
return $this->tenantRepository()->listByIds($tenantIds);
return $this->tenantRepository->listByIds($tenantIds);
}
public function findTenant(int $tenantId): ?array
{
return $this->tenantRepository()->find($tenantId);
return $this->tenantRepository->find($tenantId);
}
public function findTenantByUuid(string $tenantUuid): ?array
{
return $this->tenantRepository()->findByUuid($tenantUuid);
return $this->tenantRepository->findByUuid($tenantUuid);
}
public function listActiveTenantIdsByIds(array $tenantIds): array
{
return $this->tenantRepository()->listActiveIdsByIds($tenantIds);
return $this->tenantRepository->listActiveIdsByIds($tenantIds);
}
public function listActiveRoleIds(): array
{
return $this->roleRepository()->listActiveIds();
return $this->roleRepository->listActiveIds();
}
public function listRolesByIds(array $roleIds): array
{
return $this->roleRepository()->listByIds($roleIds);
return $this->roleRepository->listByIds($roleIds);
}
public function listDepartmentsByIds(array $departmentIds, bool $includeInactive = true): array
{
return $this->departmentRepository()->listByIds($departmentIds, $includeInactive);
return $this->departmentRepository->listByIds($departmentIds, $includeInactive);
}
public function listActiveDepartmentIdsByTenantIds(array $tenantIds): array
{
return $this->departmentRepository()->listActiveIdsByTenantIds($tenantIds);
return $this->departmentRepository->listActiveIdsByTenantIds($tenantIds);
}
public function listDepartmentsByTenantIds(array $tenantIds): array
{
return $this->departmentRepository()->listByTenantIds($tenantIds);
}
private function tenantRepository(): TenantRepositoryInterface
{
return $this->userRepositoryFactory->createTenantRepository();
}
private function roleRepository(): RoleRepositoryInterface
{
return $this->userRepositoryFactory->createRoleRepository();
}
private function departmentRepository(): DepartmentRepositoryInterface
{
return $this->userRepositoryFactory->createDepartmentRepository();
return $this->departmentRepository->listByTenantIds($tenantIds);
}
}

View File

@@ -4,6 +4,7 @@ namespace MintyPHP\Service\User;
use MintyPHP\Service\Access\AccessServicesFactory;
use MintyPHP\Service\Access\PermissionGateway;
use MintyPHP\Service\Directory\DirectoryRepositoryFactory;
use MintyPHP\Service\Settings\SettingGateway;
use MintyPHP\Service\Settings\SettingServicesFactory;
use MintyPHP\Service\Tenant\TenantScopeService;
@@ -18,10 +19,10 @@ class UserGatewayFactory
private ?UserPermissionGateway $userPermissionGateway = null;
public function __construct(
private readonly UserRepositoryFactory $userRepositoryFactory,
private readonly AccessServicesFactory $accessServicesFactory,
private readonly SettingServicesFactory $settingServicesFactory,
private readonly TenantScopeService $tenantScopeService
private readonly TenantScopeService $tenantScopeService,
private readonly DirectoryRepositoryFactory $directoryRepositoryFactory,
) {
}
@@ -37,7 +38,11 @@ class UserGatewayFactory
public function createUserDirectoryGateway(): UserDirectoryGateway
{
return $this->userDirectoryGateway ??= new UserDirectoryGateway($this->userRepositoryFactory);
return $this->userDirectoryGateway ??= new UserDirectoryGateway(
$this->directoryRepositoryFactory->createTenantRepository(),
$this->directoryRepositoryFactory->createRoleRepository(),
$this->directoryRepositoryFactory->createDepartmentRepository(),
);
}
public function createUserPermissionGateway(): UserPermissionGateway
@@ -54,5 +59,4 @@ class UserGatewayFactory
{
return $this->settingGateway ??= $this->settingServicesFactory->createSettingGateway();
}
}

View File

@@ -2,16 +2,10 @@
namespace MintyPHP\Service\User;
use MintyPHP\Repository\Access\RoleRepository;
use MintyPHP\Repository\Access\RoleRepositoryInterface;
use MintyPHP\Repository\Access\UserRoleRepository;
use MintyPHP\Repository\Access\UserRoleRepositoryInterface;
use MintyPHP\Repository\Org\DepartmentRepository;
use MintyPHP\Repository\Org\DepartmentRepositoryInterface;
use MintyPHP\Repository\Org\UserDepartmentRepository;
use MintyPHP\Repository\Org\UserDepartmentRepositoryInterface;
use MintyPHP\Repository\Tenant\TenantRepository;
use MintyPHP\Repository\Tenant\TenantRepositoryInterface;
use MintyPHP\Repository\Tenant\UserTenantRepository;
use MintyPHP\Repository\Tenant\UserTenantRepositoryInterface;
use MintyPHP\Repository\User\UserListQueryRepository;
@@ -29,9 +23,6 @@ class UserRepositoryFactory
private ?UserWriteRepository $userWriteRepository = null;
private ?UserListQueryRepository $userListQueryRepository = null;
private ?UserSavedFilterRepository $userSavedFilterRepository = null;
private ?TenantRepository $tenantRepository = null;
private ?RoleRepository $roleRepository = null;
private ?DepartmentRepository $departmentRepository = null;
private ?UserTenantRepository $userTenantRepository = null;
private ?UserRoleRepository $userRoleRepository = null;
private ?UserDepartmentRepository $userDepartmentRepository = null;
@@ -56,21 +47,6 @@ class UserRepositoryFactory
return $this->userSavedFilterRepository ??= new UserSavedFilterRepository();
}
public function createTenantRepository(): TenantRepositoryInterface
{
return $this->tenantRepository ??= new TenantRepository();
}
public function createRoleRepository(): RoleRepositoryInterface
{
return $this->roleRepository ??= new RoleRepository();
}
public function createDepartmentRepository(): DepartmentRepositoryInterface
{
return $this->departmentRepository ??= new DepartmentRepository();
}
public function createUserTenantRepository(): UserTenantRepositoryInterface
{
return $this->userTenantRepository ??= new UserTenantRepository();

View File

@@ -31,7 +31,8 @@ class UserServicesFactory
private readonly UserRepositoryFactory $userRepositoryFactory,
private readonly UserGatewayFactory $userGatewayFactory,
private readonly DatabaseSessionRepository $databaseSessionRepository
) {}
) {
}
public function createUserAccountService(): UserAccountService
{