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

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.

    # 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

    Dompdf\Dompdf:
        arguments:
            - '@Dompdf\Options'

    Dompdf\Options:
        arguments:
            - is_remote_enabled: true

    App\Service\Pdf\PdfGeneratorService:
        arguments:
            - '@twig'
            - '@Dompdf\Dompdf'

    App\Service\MenuService:
        arguments:
            $security: '@App\Controller\SecurityController'

    App\Service\Common\ImageEncoderService:
        arguments:
            $projectDir: '%kernel.project_dir%'

    # Tells Symfony to replace abstract interfaces with these specific concrete implementations
    # It will be donne automatically during auto-injection
    App\Client\ApiClientInterface: '@App\Client\EndpointsApiClient'

    App\Client\EndpointsApiClient:
        arguments:
            $endpointsApiUrl: '%env(ENDPOINTS_API_URL)%'

    App\Service\Endpoints\ApiTokenProviderService:
        arguments:
            $endpointsApiUrl: '%env(ENDPOINTS_API_URL)%'

    App\Client\OptimusApiClient:
        arguments:
            $optimusApiUrl: '%env(OPTIMUS_API_URL)%'

    Redis:
        # you can also use \RedisArray, \RedisCluster or \Predis\Client classes
        class: \Predis\Client
        arguments:
            - "%env(REDIS_URL)%"
            # If your Redis server requires a password, uncomment the following lines:
            - password: "%env(REDIS_AUTH)%"

    Symfony\Contracts\Cache\CacheInterface:
        class: Symfony\Component\Cache\Adapter\RedisAdapter
        arguments:
            $redis: '@Redis'
            $namespace: 'MG'
            $defaultLifetime: 36000 # cache lifetime of 10 hour

    Symfony\Component\HttpFoundation\Session\Storage\Handler\RedisSessionHandler:
        arguments:
            - '@Redis'

    App\Service\UserManagerService:
        arguments:
            $redisUrl: "%env(REDIS_URL)%"

    App\Command\MagestionRefreshCachedUsersCommand:
        arguments:
            $redisUrl: "%env(REDIS_URL)%"
