# 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:
    locale: fr
    app_locales: fr
    avatars_directory: '%kernel.project_dir%/public/uploads/avatars'
    organization_logo: '%kernel.project_dir%/public/uploads/logo'
    openai.api_key: '%env(OPENAI_API_KEY)%'
    openai.api_url:  '%env(OPENAI_API_URL)%'
    default_email_sender: '%env(EMAIL_SEND_METHOD)%'  # mailgun or sendgrid
    mailgun_api_key: '%env(MAILGUN_API_KEY)%'
    mailgun_domain: '%env(MAILGUN_DOMAIN)%'
    sendgrid_api_key: '%env(SENDGRID_API_KEY)%'
    uploads_dir_name: 'uploads'
    uploads_base_url: '%env(SITE_BASE_URL)%/%uploads_dir_name%'
    avatar_dir: 'image/avatar'

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:
            $defaultEmailSender: '%default_email_sender%'
            $uploadsDirName: '%uploads_dir_name%'
            $uploadedAssetsBaseUrl: '%uploads_base_url%'
            $publicUploadsFilesystem: '@oneup_flysystem.public_uploads_filesystem_filesystem'
            $privateUploadsFilesystem: '@oneup_flysystem.private_uploads_filesystem_filesystem'
            $avatarDirectory: '%avatar_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\Twig\DurationExtension:
        tags: ['twig.extension']

    App\Domain\Services\AI\OpenAiAPIService:
        arguments:
            $apiKey: '%openai.api_key%'
            $apiUrl: '%openai.api_url%'


    App\Domain\Contracts\EmailSenderInterface:
        alias: App\Domain\Services\Notification\Sender\SendEmailHandler

    # Service Mailgun
    App\Domain\Services\Notification\Sender\MailgunEmailSender:
        arguments:
            $mailgunApiKey: '%mailgun_api_key%'
            $mailgunDomain: '%mailgun_domain%'

    # Service SendGrid
    App\Domain\Services\Notification\Sender\SendgridEmailSender:
        arguments:
            $sendgridApiKey: '%sendgrid_api_key%'

    App\EventListener\ParamConverterExceptionListener:
        tags:
            - { name: kernel.event_listener, event: kernel.exception }

    Symfony\Component\Asset\Context\RequestStackContext: '@assets.context'

    App\Domain\Services\Dashboard\:
        resource: '../src/Domain/Services/Dashboard/*'
        tags: ['app.kpi_calculator']

    App\Domain\Services\Dashboard\KpiCalculatorRegistry:
        arguments:
            $calculators: !tagged_iterator app.kpi_calculator
