parameters:
    app.url: '%env(APP_URL)%'
    frontend.url: '%env(FRONTEND_URL)%'

services:
    _defaults:
        autowire: true
        autoconfigure: true
        bind:
            string $appUrl: '%app.url%'

    App\:
        resource: '../src/'
        exclude:
            - '../src/DependencyInjection/'
            - '../src/Entity/'
            - '../src/Kernel.php'

    # State Processor for User Password Hashing
    App\State\UserPasswordHasher:
        arguments:
            $processor: '@api_platform.doctrine.orm.state.persist_processor'
            $passwordHasher: '@Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface'
            $mailer: '@Symfony\Component\Mailer\MailerInterface'
            $appUrl: '%app.url%'
        tags:
            - { name: 'api_platform.state_processor', priority: 10 }

    # Email Verification Listener
    App\EventListener\EmailVerificationListener:
        tags:
            - { name: kernel.event_listener, event: lexik_jwt_authentication.on_authentication_success, method: onAuthenticationSuccess }

    # Controllers
    App\Controller\ForgotPasswordController:
        arguments:
            $em: '@doctrine.orm.entity_manager'
            $mailer: '@Symfony\Component\Mailer\MailerInterface'
            $appUrl: '%app.url%'
            $frontendUrl: '%frontend.url%'
        tags: ['controller.service_arguments']

    App\Controller\ResetPasswordController:
        arguments:
            $em: '@doctrine.orm.entity_manager'
            $passwordHasher: '@Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface'
        tags: ['controller.service_arguments']

    App\Controller\VerifyEmailController:
        arguments:
            $em: '@doctrine.orm.entity_manager'
        tags: ['controller.service_arguments']

    App\Controller\ResendVerificationController:
        arguments:
            $em: '@doctrine.orm.entity_manager'
            $mailer: '@Symfony\Component\Mailer\MailerInterface'
            $appUrl: '%app.url%'
        tags: ['controller.service_arguments']

    App\EventListener\JWTCreatedListener:
            tags:
                - { name: kernel.event_listener, event: lexik_jwt_authentication.on_jwt_created, method: onJWTCreated }

    App\EventSubscriber\PracticeTestSubscriber:
        arguments:
            $questionRepository: '@App\Repository\QuestionRepository'
        tags:
            - { name: kernel.event_subscriber }

    App\State\SubscriptionProcessor:
        arguments:
            $persistProcessor: '@api_platform.doctrine.orm.state.persist_processor'
