parameters:
    upload_directory: "%env(resolve:UPLOAD_DIR)%"
    keycloak_realm: "%env(resolve:KEYCLOAK_REALM)%"
    keycloak_url: "%env(resolve:KEYCLOAK_URL)%"
    mailbox_host: "%env(resolve:MAILBOX_HOST)%"
    mailbox_username: "%env(resolve:MAILBOX_USERNAME)%"
    mailbox_password: "%env(resolve:MAILBOX_PASSWORD)%"
    trello_apikey: "%env(resolve:TRELLO_API_KEY)%"
    trello_apitoken: "%env(resolve:TRELLO_API_TOKEN)%"
    sharepoint_tenant_id: "%env(resolve:SHAREPOINT_TENANT_ID)%"
    sharepoint_client_id: "%env(resolve:SHAREPOINT_CLIENT_ID)%"
    sharepoint_client_secret: "%env(resolve:SHAREPOINT_CLIENT_SECRET)%"
    sharepoint_site_urls:
        alphacee: "%env(resolve:SHAREPOINT_ALPHACEE_SITE_URL)%"
        enership: "%env(resolve:SHAREPOINT_ENERSHIP_SITE_URL)%"
    sharepoint_doc_libraries:
        alphacee: "%env(resolve:SHAREPOINT_ALPHACEE_DOCUMENT_LIBRARY)%"
        enership: "%env(resolve:SHAREPOINT_ENERSHIP_DOCUMENT_LIBRARY)%"
    connections:
        a-gile.fr:
            host: "%env(SFTP_A_GILE_FR_HOST)%"
            username: "%env(SFTP_A_GILE_FR_USER)%"
            password: "%env(SFTP_A_GILE_FR_PASSWORD)%"
            root: "%env(SFTP_A_GILE_FR_ROOT)%"
        a-gile.site:
            host: "%env(SFTP_A_GILE_SITE_HOST)%"
            username: "%env(SFTP_A_GILE_SITE_USER)%"
            password: "%env(SFTP_A_GILE_SITE_PASSWORD)%"
            root: "%env(SFTP_A_GILE_SITE_ROOT)%"

services:
    _defaults:
        autowire: true
        autoconfigure: true
        bind:
            string $mailboxHost: "%mailbox_host%"
            string $mailboxUsername: "%mailbox_username%"
            string $mailboxPassword: "%mailbox_password%"
            string $apiKey: "%trello_apikey%"
            string $apiToken: "%trello_apitoken%"
            string $tenantId: "%sharepoint_tenant_id%"
            string $clientId: "%sharepoint_client_id%"
            string $clientSecret: "%sharepoint_client_secret%"
            array $siteUrls: "%sharepoint_site_urls%"
            array $docLibraries: "%sharepoint_doc_libraries%"
            string $uploadDirectory: "%upload_directory%"
            array $connections: "%connections%"

    App\Service\Config\FtpClientService:
        autowire: false
        autoconfigure: false
        arguments:
            $connections: "%connections%"

    App\Service\Config\SharepointService:
        arguments:
            $tenantId: "%sharepoint_tenant_id%"
            $clientId: "%sharepoint_client_id%"
            $clientSecret: "%sharepoint_client_secret%"
            $siteUrls: "%sharepoint_site_urls%"
            $docLibraries: "%sharepoint_doc_libraries%"

    # ----------------------------
    # Normalizers / Denormalizers
    # ----------------------------
    App\Serializer\SharedNormalizer:
        tags:
            # register the normalizer with a high priority (called earlier)
            - { name: "serializer.normalizer", priority: 500 }

    App\Serializer\SharedDenormalizer:
        arguments:
            $entityManager: "@doctrine.orm.entity_manager"
            $normalizer: '@Symfony\Component\Serializer\Normalizer\ObjectNormalizer'
        tags: ["serializer.normalizer"]

    # Symfony normalizer de base
    Symfony\Component\Serializer\Normalizer\ObjectNormalizer: ~

    App\Doctrine\ConnectionResolver: ~

    App\EventListener\PersistListener:
        arguments:
            $tokenStorage: "@security.token_storage"
        tags:
            - { name: doctrine.event_listener, event: prePersist }

    App\Service\Config\MailBoxService:
        arguments:
            $mailboxHost: "%mailbox_host%"
            $mailboxUsername: "%mailbox_username%"
            $mailboxPassword: "%mailbox_password%"

    App\Service\Config\TrelloService:
        arguments:
            $apiKey: "%trello_apikey%"
            $apiToken: "%trello_apitoken%"

    App\Service\Business\Other\DocumentService:
        arguments:
            $uploadDirectory: "%upload_directory%"

    # App\Serializer\ReportNormalizer:
    #     arguments:
    #         $normalizer: '@Symfony\Component\Serializer\Normalizer\ObjectNormalizer'
    #         $userService: '@App\Service\Security\UserService'
    #     tags:
    #         - { name: "serializer.normalizer" }

    # ----------------------------
    # Repositories
    # ----------------------------

    App\Domain\Project\Port\ProjectRepositoryInterface:
        alias: App\Infrastructure\Persistence\Doctrine\Repository\DoctrineProjectRepository

    App\Domain\Potential\Port\PotentialRepositoryInterface:
        alias: App\Infrastructure\Persistence\Doctrine\Repository\DoctrinePotentialRepository

    # ----------------------------
    # Auto-registration of services
    # ----------------------------
    App\:
        resource: "../src/"
        exclude:
            - "../src/DependencyInjection/"
            - "../src/Entity/"
            - "../src/Kernel.php"
