# Put parameters here that don't need to change on each machine where the app is deployed
# https://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
parameters:

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:
            $opentalentConfig: '%kernel.project_dir%%env(OPENTALENT_CONFIG)%'
            $internalFilesUploadUri: '%env(INTERNAL_FILES_DOWNLOAD_URI)%'
            $bindfileBufferFile: '%env(BIND_FILE_BUFFER_FILE)%'
            $contextAwareDataPersister: '@api_platform.doctrine.orm.data_persister'
            $opentalentNoReplyEmailAddress: 'noreply@opentalent.fr'

    # Logging: a shorter version of the default monolog line formatter
    monolog.formatter.message:
        class: Monolog\Formatter\LineFormatter
        arguments:
            - "[%%datetime%%] %%level_name%% : %%message%%\n"
            - "Y-m-d H:i:s.v"

    # 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'
            - '../src/Tests/'

    App\OpenApi\OpenApiFactory:
        decorates: 'api_platform.openapi.factory'
        arguments: [ '@App\OpenApi\OpenApiFactory.inner' ]
        autoconfigure: false

    App\Service\Cotisation\Utils:
        public: true

    App\Service\Network\Utils:
        public: true

    App\Service\Organization\Utils:
        public: true

    Gaufrette\Filesystem: '@knp_gaufrette.filesystem_map'

    #########################################
    ##  TAG Services ##
    _instanceof:
        App\Doctrine\Access\AccessExtensionInterface:
            tags: ['app.extensions.access']
        App\Service\Access\OptionalsRolesInterface:
            tags: ['app.optionalsroles']
        App\Service\Export\ExporterInterface:
            tags: ['app.exporter']
        App\Service\Export\Encoder\EncoderInterface:
            tags: ['app.encoder']
        App\Service\Mailer\Builder\BuilderInterface:
            tags: [ 'app.mailer.builder' ]
        App\Service\Twig\AssetsExtension:
            tags: [ 'twig.extension' ]

    App\Service\ServiceIterator\CurrentAccessExtensionIterator:
        - !tagged_iterator app.extensions.access
    App\Service\ServiceIterator\OptionalsRolesIterator:
        - !tagged_iterator app.optionalsroles
    App\Service\ServiceIterator\ExporterIterator:
        - !tagged_iterator app.exporter
    App\Service\ServiceIterator\EncoderIterator:
        - !tagged_iterator app.encoder
    App\Service\ServiceIterator\Mailer\BuilderIterator:
        - !tagged_iterator app.mailer.builder

    App\Service\Dolibarr\DolibarrSyncService:
        tags:
            - { name: monolog.logger, channel: dolibarrsync }

    #########################################
    ##  SERIALIZER Decorates ##
    App\Serializer\DefaultNormalizer:
        # By default .inner is passed as argument
        decorates: 'api_platform.jsonld.normalizer.item'

    app.serializer.normalizer.item.json:
        class: 'App\Serializer\DefaultNormalizer'
        decorates: 'api_platform.serializer.normalizer.item'

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

    #########################################
    ##  LISTENER ##
    App\EventListener\DoctrineFilter\DoctrineFilterListener:
        tags:
            - { name: kernel.event_listener, event: kernel.request }

    #########################################
    ##  ELASTIC SERVICE ##
    App\Service\Elasticsearch\EducationNotationUpdater:
        arguments:
            - '@fos_elastica.object_persister.search.educationNotation'
