<?php

namespace MintyPHP\Service\Access;

use MintyPHP\Http\SessionStoreInterface;
use MintyPHP\Service\Audit\AuditServicesFactory;

class AccessGatewayFactory
{
    private ?PermissionService $permissionService = null;

    public function __construct(
        private readonly AccessRepositoryFactory $accessRepositoryFactory,
        private readonly AuditServicesFactory $auditServicesFactory,
        private readonly SessionStoreInterface $sessionStore
    ) {
    }

    public function createPermissionService(): PermissionService
    {
        return $this->permissionService ??= new PermissionService(
            $this->accessRepositoryFactory->createPermissionRepository(),
            $this->accessRepositoryFactory->createRolePermissionRepository(),
            $this->accessRepositoryFactory->createUserRoleRepository(),
            $this->auditServicesFactory->createSystemAuditService(),
            $this->sessionStore
        );
    }

}
