# 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:
    # App
    app.url: '%env(APP_URL)%'
    app.version: '%env(default:app.default.version:APP_VERSION)%'

    # Debrid Services
    app.debrid.real_debrid.key: '%env(REAL_DEBRID_KEY)%'

    # TMDB Key
    app.meta_provider.tmdb.key: '%env(TMDB_API)%'

    # Media
    media.base_path: '/var/download'
    media.default_movies_dir: movies
    media.default_tvshows_dir: tvshows
    media.movies_path: '/var/download/%env(default:media.default_movies_dir:MOVIES_PATH)%'
    media.tvshows_path: '/var/download/%env(default:media.default_tvshows_dir:TVSHOWS_PATH)%'

    # Mercure
    app.mercure.url: 'http://app/.well-known/mercure'
    app.mercure.public_url: '%env(APP_URL)%/.well-known/mercure'

    # Cache
    app.cache.adapter: '%env(default:app.cache.adapter.default:CACHE_ADAPTER)%'
    app.cache.redis.host: '%env(default:app.cache.redis.host.default:REDIS_HOST)%'
    app.cache.adapter.default: 'filesystem'
    app.cache.redis.host.default: 'redis://redis'

    # Various configs
    app.default.version: '0.0.0-dev'
    app.default.timezone: 'America/Chicago'

    # Auth
    auth.default.method: 'form_login'
    auth.method: '%env(default:auth.default.method:AUTH_METHOD)%'

    auth.oidc.well_known_url: '%env(OIDC_WELL_KNOWN_URL)%'
    auth.oidc.client_id: '%env(OIDC_CLIENT_ID)%'
    auth.oidc.client_secret: '%env(OIDC_CLIENT_SECRET)%'
    auth.oidc.bypass_form_login: '%env(bool:OIDC_BYPASS_FORM_LOGIN)%'

    # Notifications
    notification.transport: '%env(NOTIFICATION_TRANSPORT)%'
    notification.ntfy.dsn: '%env(NTFY_DSN)%'

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
    App\Download\Downloader\DownloaderInterface: "@App\\Download\\Downloader\\ProcessDownloader"

    # Session
    Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler:
        arguments:
            - '%env(DATABASE_URL)%'

    # LDAP
    App\User\Framework\Security\LdapUserProvider:
        arguments:
            $registerLdapUserHandler: '@App\User\Action\Handler\RegisterLdapUserHandler'
            $userRepository: '@App\User\Framework\Repository\UserRepository'
            $ldap: '@Symfony\Component\Ldap\LdapInterface'
            $baseDn: '%env(LDAP_BASE_DN)%'
            $searchDn: '%env(LDAP_BIND_USER)%'
            $searchPassword: '%env(LDAP_BIND_PASS)%'
            $defaultRoles: ['ROLE_USER']
            $uidKey: '%env(LDAP_UID_KEY)%'
#            $passwordAttribute: '%env(LDAP_PASSWORD_ATTRIBUTE)%'


    Symfony\Component\Ldap\LdapInterface: '@Symfony\Component\Ldap\Ldap'

    Symfony\Component\Ldap\Ldap:
        arguments: [ '@Symfony\Component\Ldap\Adapter\ExtLdap\Adapter' ]
        tags:
            - ldap

    Symfony\Component\Ldap\Adapter\ExtLdap\Adapter:
        arguments:
            - host: '%env(LDAP_HOST)%'
              port: '%env(LDAP_PORT)%'
              encryption: '%env(LDAP_ENCRYPTION)%'
              options:
                  protocol_version: 3
                  referrals: false

