# This file is the entry point to configure your own services.
# Files in the packages/ subdirectory configure your dependencies.

# Put parameters here that don't need to change on each machine where the app is deployed
# https://symfony.com/doc/current/best_practices.html#use-parameters-for-application-configuration
parameters:
    confirm_type: '%env(CONFIRM_TYPE)%'
    code_ttl: '%env(CODE_TTL)%'
    from_email: '%env(MAILER_ADDRESS)%'
    # Директория сохранения файлов
    images_directory: '%kernel.project_dir%/public/uploads/user_images'

services:
    # default configuration for services in *this* file
    _defaults:
        autowire: true      # Automatically injects dependencies in your services.
        autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.

    # makes classes in src/ available to be used as services
    # this creates a service per class whose id is the fully-qualified class name
    App\:
        resource: '../src/'
        exclude:
            - '../src/DependencyInjection/'
            - '../src/Entity/'
            - '../src/Kernel.php'

    App\Service\Action\Classes\SaveImage:
        arguments:
            $targetDirectory: '%images_directory%'


    # Сервис отправки
    App\Service\Send\SendService:
        arguments:
            $confirmType: '%confirm_type%'
            $fromEmail: '%from_email%'

    App\Messenger\Handler\QuestEndMessageHandler:
        arguments:
            $fromEmail: '%from_email%'

    App\Messenger\Handler\QuestStartMessageHandler:
        arguments:
            $fromEmail: '%from_email%'

    App\Listeners\KernelExceptionListener:
        tags:
            - { name: kernel.event_listener, event: kernel.exception }

    # События JWT авторизации
    acme_api.event.authentication_success_listener:
        class: App\Listeners\JwtListener
        tags:
            - { name: kernel.event_listener, event: lexik_jwt_authentication.on_authentication_success, method: onAuthenticationSuccessResponse }

    acme_api.event.authentication_failure_listener:
        class: App\Listeners\JwtListener
        tags:
            - { name: kernel.event_listener, event: lexik_jwt_authentication.on_authentication_failure, method: onAuthenticationFailureResponse }

    acme_api.event.jwt_invalid_listener:
        class: App\Listeners\JwtListener
        tags:
            - { name: kernel.event_listener, event: lexik_jwt_authentication.on_jwt_invalid, method: onJWTInvalid }

    acme_api.event.jwt_notfound_listener:
        class: App\Listeners\JwtListener
        tags:
            - { name: kernel.event_listener, event: lexik_jwt_authentication.on_jwt_not_found, method: onJWTNotFound }

    acme_api.event.jwt_expired_listener:
        class: App\Listeners\JwtListener
        tags:
            - { name: kernel.event_listener, event: lexik_jwt_authentication.on_jwt_expired, method: onJWTExpired }

    gesdinet.jwtrefreshtoken.send_token:
        class: App\Listeners\JwtRefreshListener
        arguments:
            - '@gesdinet.jwtrefreshtoken.refresh_token_manager'
            - '%gesdinet_jwt_refresh_token.ttl%'
            - '@request_stack'
            - '%gesdinet_jwt_refresh_token.token_parameter_name%'
            - '%gesdinet_jwt_refresh_token.single_use%'
            - '@gesdinet.jwtrefreshtoken.refresh_token_generator'
            - '@gesdinet.jwtrefreshtoken.request.extractor.chain'
            - '%gesdinet_jwt_refresh_token.cookie%'
            - '%gesdinet_jwt_refresh_token.return_expiration%'
            - '%gesdinet_jwt_refresh_token.return_expiration_parameter_name%'
        tags:
            - { name: kernel.event_listener, event: lexik_jwt_authentication.on_authentication_success, method: attachRefreshToken }