# 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:
    logo_path: '%kernel.project_dir%/public/images/polaris.png'
    mailer_from: 'no-reply@polarisnextgen.com'
    #Define directory used for save images og users avatar
    avatar_directory: '%kernel.project_dir%/public/uploads/avatar'
    # Define constant to access public directory
    public_dir: '%kernel.project_dir%/public'
    upload_dir: '%kernel.project_dir%/public/files'
    temp_dir: '%kernel.project_dir%/var'
    
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.
        bind:
            string $projectDir: '%kernel.project_dir%'

    # 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'

    # add more service definitions when explicit configuration is needed
    # please note that last definitions always *replace* previous ones

    App\Events\User\LoginListener:
        tags:
            - { name: kernel.event_listener, event: security.interactive_login, method: onSecurityInteractiveLogin }

#    App\Events\User\UserNotificationOnFormationRegister:
#        arguments:
#            $mailFrom: '%mailer_from%'
#        tags:
#            - { name: 'doctrine.orm.entity_listener', event: 'postPersist', entity: 'App\Entity\StudentFormation' }


    #Inject in Service directory path for users avatar
    App\Service\AvatarUploader:
        arguments:
            $targetDirectory: '%avatar_directory%'

    App\Service\UploaderService:
        arguments:
            $targetDirectory: '%upload_dir%'

    App\Service\UserService:
        arguments:
            $mailFrom: '%mailer_from%'

    App\Serializer\PatchedDateTimeNormalizer:
        tags: [serializer.normalizer]

    App\Events\User\UserNotificationOnCreate:
        arguments:
            $mailFrom: '%mailer_from%'

    App\Serializer\AtoUserContextBuilder:
      decorates: 'api_platform.serializer.context_builder'
      arguments: ['@App\Serializer\AtoUserContextBuilder.inner']
      autoconfigure: false

    App\Serializer\FormationContextBuilder:
        decorates: 'api_platform.serializer.context_builder'
        arguments: ['@App\Serializer\FormationContextBuilder.inner']
        autoconfigure: false

    App\Events\JwtCreatedSubscriber:
        tags:
            - {name: kernel.event_listener, event: lexik_jwt_authentication.on_jwt_created, method: updateJwtData}

    App\Events\SetLocalListener:
        tags:
            - { name: kernel.event_listener, event: kernel.request, method: onKernelRequest }

    App\Events\AtoUser\OnAtoUserCreated:
        tags:
            - { name: kernel.event_listener, event: kernel.response, method: onKernelResponse }

    App\Events\AtoUser\OnAtoUserUpdated:
        tags:
            - { name: kernel.event_listener, event: kernel.response, method: onKernelResponse }

    App\Events\Aircraft\OnAircraftUpdated:
        tags:
            - { name: kernel.event_listener, event: kernel.response, method: onKernelResponse }

    App\Events\Session\OnSessionRemove:
        tags:
            name: 'doctrine.orm.entity_listener'
            event: 'preRemove'
            entity: 'App\Entity\Session\Session'
            method: 'onRemove'

    twig.extension.intl:
        class: Twig\Extensions\IntlExtension
        tags:
            - { name: twig.extension }
