instances added god may help
This commit is contained in:
42
lib/Service/Auth/AuthScopeGateway.php
Normal file
42
lib/Service/Auth/AuthScopeGateway.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace MintyPHP\Service\Auth;
|
||||
|
||||
use MintyPHP\Service\Tenant\TenantScopeService;
|
||||
use MintyPHP\Service\Tenant\TenantServicesFactory;
|
||||
|
||||
class AuthScopeGateway
|
||||
{
|
||||
public function __construct(private readonly ?TenantScopeService $tenantScopeService = null)
|
||||
{
|
||||
}
|
||||
|
||||
public function hasGlobalAccess(int $userId): bool
|
||||
{
|
||||
return $this->tenantScopeService()->hasGlobalAccess($userId);
|
||||
}
|
||||
|
||||
public function getUserTenantIds(int $userId): array
|
||||
{
|
||||
return $this->tenantScopeService()->getUserTenantIds($userId);
|
||||
}
|
||||
|
||||
public function canAccess(string $resourceType, int $resourceId, int $userId): bool
|
||||
{
|
||||
return $this->tenantScopeService()->canAccess($resourceType, $resourceId, $userId);
|
||||
}
|
||||
|
||||
public function resourceBelongsToTenant(string $resourceType, int $resourceId, int $tenantId): bool
|
||||
{
|
||||
return $this->tenantScopeService()->resourceBelongsToTenant($resourceType, $resourceId, $tenantId);
|
||||
}
|
||||
|
||||
private function tenantScopeService(): TenantScopeService
|
||||
{
|
||||
if ($this->tenantScopeService instanceof TenantScopeService) {
|
||||
return $this->tenantScopeService;
|
||||
}
|
||||
|
||||
return (new TenantServicesFactory())->createTenantScopeService();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user