# yaml-language-server: $schema=../vendor/symfony/dependency-injection/Loader/schema/services.schema.json

parameters:

services:
    _defaults:
        autowire: true
        autoconfigure: true

    App\:
        resource: '../src/'
        exclude:
            - '../src/Domain/'
            - '../src/Kernel.php'
            - '../src/Infrastructure/Auth/SymfonyUser.php'

    ##########################################################
    # Relie les interfaces à leurs implémentations
    ##########################################################

    App\Application\Port\Repository\UserRepositoryInterface:
        class: App\Infrastructure\Persistence\Doctrine\Repository\DoctrineUserRepository

    App\Application\Port\Service\JwtServiceInterface:
        class: App\Infrastructure\Auth\JwtService

    App\Application\Port\Service\PasswordHasherInterface:
        class: App\Infrastructure\Auth\PasswordHasher

    App\Application\Port\Service\OAuthServiceInterface:
        class: App\Infrastructure\Auth\OAuth\GoogleOAuthService

    # 2FA
    App\Application\Port\Repository\TwoFactorRepositoryInterface:
        class: App\Infrastructure\Persistence\Doctrine\Repository\DoctrineTwoFactorRepository

    # Reset password
    App\Application\Port\Repository\ResetPasswordRepositoryInterface:
        class: App\Infrastructure\Persistence\Doctrine\Repository\DoctrineResetPasswordRepository

    App\Application\Port\Service\MailServiceInterface:
        class: App\Infrastructure\Mail\SymfonyMailerService
        arguments:
            $expediteur: 'gestionprojetwde@gmail.com'

    App\Infrastructure\Auth\SymfonyUser:
        autowire: false
        autoconfigure: false

    # Vérification email  
    App\Application\Port\Repository\EmailVerificationRepositoryInterface:
        class: App\Infrastructure\Persistence\Doctrine\Repository\DoctrineEmailVerificationRepository

    App\Application\UseCase\Api\Auth\SendVerificationEmailUseCase:
        arguments:
            $frontUrl: '%env(APP_FRONT_URL)%'

    App\Application\UseCase\Api\Auth\ForgotPasswordUseCase:
        arguments:
            $frontUrl: '%env(APP_FRONT_RESET_URL)%'

    App\Application\UseCase\Api\Auth\VerifyEmailUseCase:
        arguments:
            $frontUrl: '%env(APP_URL)%'

    App\Application\UseCase\Back\Auth\AdminForgotPasswordUseCase:
            arguments:
                $frontAdminResetUrl: '%env(APP_FRONT_ADMIN_RESET_URL)%'

    # Refresh token
    App\Application\Port\Repository\RefreshTokenRepositoryInterface:
        class: App\Infrastructure\Persistence\Doctrine\Repository\DoctrineRefreshTokenRepository


    # Connection logs
    App\Application\Port\Repository\ConnectionLogRepositoryInterface:
        class: App\Infrastructure\Persistence\Doctrine\Repository\DoctrineConnectionLogRepository



    #listner 

    
    App\Application\EventListener\Auth\ConnectionLogListener:
        tags:
            - { name: kernel.event_listener, event: App\Domain\Log\UserLoggedInEvent, method: onUserLoggedIn }
            - { name: kernel.event_listener, event: App\Domain\Log\UserLoggedOutEvent, method: onUserLoggedOut }