Files
breadcrumb-the-shire/lib/Service/AddressBook/AddressBookDirectoryGateway.php

75 lines
1.8 KiB
PHP
Raw Normal View History

2026-02-23 12:58:19 +01:00
<?php
namespace MintyPHP\Service\AddressBook;
use MintyPHP\Service\Directory\DirectoryScopeGateway;
use MintyPHP\Service\Access\RoleService;
use MintyPHP\Service\Org\DepartmentService;
use MintyPHP\Service\Tenant\TenantService;
class AddressBookDirectoryGateway
{
public function __construct(
2026-03-04 15:56:58 +01:00
private readonly TenantService $tenantService,
private readonly DepartmentService $departmentService,
private readonly RoleService $roleService,
private readonly DirectoryScopeGateway $scopeGateway
2026-02-23 12:58:19 +01:00
) {
}
public function listTenants(): array
{
return $this->tenantService()->list();
}
public function listDepartmentsByTenantIds(array $tenantIds): array
{
return $this->departmentService()->listByTenantIds($tenantIds);
}
public function listDepartments(): array
{
return $this->departmentService()->list();
}
public function listActiveRoles(): array
{
return $this->roleService()->listActive();
}
public function getUserTenantIds(int $userId): array
{
return $this->scopeGateway()->getUserTenantIds($userId);
}
public function isStrictScope(): bool
{
return $this->scopeGateway()->isStrict();
}
public function canAccessUser(int $viewerUserId, int $targetUserId): bool
{
return $this->scopeGateway()->canAccess('users', $targetUserId, $viewerUserId);
}
private function tenantService(): TenantService
{
2026-03-04 15:56:58 +01:00
return $this->tenantService;
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
}
private function roleService(): RoleService
{
2026-03-04 15:56:58 +01:00
return $this->roleService;
2026-02-23 12:58:19 +01:00
}
private function scopeGateway(): DirectoryScopeGateway
{
2026-03-04 15:56:58 +01:00
return $this->scopeGateway;
2026-02-23 12:58:19 +01:00
}
}