# 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:
    cas_login_target: '%env(string:CAS_LOGIN_TARGET)%'
    cas_logout_target: '%env(string:CAS_LOGIN_TARGET)%'
    cas_host: '%env(string:CAS_HOST)%'
    cas_port: '%env(int:CAS_PORT)%'
    cas_path: '%env(string:CAS_PATH)%'
    cas_gateway: '%env(bool:CAS_GATEWAY)%'

#2HAL
    cas_login_target2: '%env(string:CAS_LOGIN_TARGET2)%'
    cas_logout_target2: '%env(string:CAS_LOGIN_TARGET2)%'
    cas_host2: '%env(string:CAS_HOST2)%'
    cas_port2: '%env(int:CAS_PORT2)%'
    cas_path2: '%env(string:CAS_PATH2)%'
    cas_gateway2: '%env(bool:CAS_GATEWAY2)%'

l3_cas_guard:
    host: '%env(string:CAS_HOST)%'
    path: '%env(string:CAS_PATH)%'
    port: '%env(int:CAS_PORT)%'
    ca: '%env(bool:CAS_CA)%'
    handleLogoutRequest: '%env(bool:CAS_HANDLE_LOGOUT_REQUEST)%'
    casLogoutTarget: '%env(string:CAS_LOGOUT_TARGET)%'
    force: '%env(bool:CAS_FORCE)%'
    gateway: '%env(bool:CAS_GATEWAY)%'

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.

    authentication_handler:
        class: App\Handler\AuthenticationHandler
        arguments: ['%cas_logout_target%']
        public: false


    # 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\Controller\:
        resource: '../src/Controller/'
        tags: ['controller.service_arguments']
    # add more service definitions when explicit configuration is needed
    # please note that last definitions always *replace* previous ones

    # App\Service\DataverseService:
    #     arguments:
    #         $client: '@dataverse.client'

    # dataverse.client:
    #     class: Symfony\Contracts\HttpClient\HttpClientInterface
    #     factory: ['@http_client', 'withOptions']
    #     arguments:
    #         - { base_uri: 'https://demo.dataverse.org/api/dataverses/root/' }
    App\Service\DataverseService:
        arguments:
            $client: '@dataverse.client'

    dataverse.client:
        class: Symfony\Contracts\HttpClient\HttpClientInterface
        factory: ['@http_client', 'withOptions']
        arguments:
            - { base_uri: 'https://entrepot.recherche.data.gouv.fr/api/' }

    App\Security\OrcidAuthenticator:
        arguments:
            $router: '@router'
        tags:
            - { name: 'security.authenticator' }