Files
breadcrumb-the-shire/lib/Service/AddressBook/AddressBookDirectoryGateway.php
2026-03-04 15:56:58 +01:00

75 lines
1.8 KiB
PHP

<?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(
private readonly TenantService $tenantService,
private readonly DepartmentService $departmentService,
private readonly RoleService $roleService,
private readonly DirectoryScopeGateway $scopeGateway
) {
}
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
{
return $this->tenantService;
}
private function departmentService(): DepartmentService
{
return $this->departmentService;
}
private function roleService(): RoleService
{
return $this->roleService;
}
private function scopeGateway(): DirectoryScopeGateway
{
return $this->scopeGateway;
}
}