# 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/configuration.html#application-related-configuration
parameters:
  php_path: '%env(PHP_PATH)%'
  app_path: '%env(APP_PATH)%'
  batch_size: '%env(BATCH_SIZE)%'
  max_processes: '%env(MAX_PROCESSES)%'
  router.request_context.host: '%env(string:APP_HOST)%'
  router.request_context.base_url: '%env(string:APP_BASE_URL)%'
  google.analytics.enable: '%env(bool:ENABLE_GOOGLE_ANALYTIC)%'
  google.analytics.id: '%env(string:GOOGLE_ANALYTIC_ID)%'
  asset.request_context.base_path: '%router.request_context.base_url%'
  referrer_url: '%env(string:REFERRER_URL)%'
  directus_api_url: '%env(DIRECTUS_HOST_NAME)%'
  directus_api_user_name: '%env(DIRECTUS_USERNAME)%'
  directus_api_credential: '%env(DIRECTUS_PASSWORD)%'
  mail_name: '%env(MAIL_NAME)%'
  mail_from: '%env(MAIL_FROM)%'
  mail_to: '%env(MAIL_TO)%'
  mail_subject: '%env(MAIL_SUBJECT)%'
  invoice_api_url: '%env(INVOICE_API_HOST_NAME)%'
  invoice_login_url: '%env(INVOICE_LOGIN_URL)%'
  invoice_api_user_name: '%env(INVOICE_API_USERNAME)%'
  invoice_api_credential: '%env(INVOICE_API_CREDENTIAL)%'

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.

  web_exception_subscriber:
    class: App\EventListener\WebExceptionSubscriber
    arguments: ['@service_container']
    tags:
      - { name: kernel.event_subscriber }

  # 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,Entity,Migrations,Tests,Kernel.php}'

  # controllers are imported separately to make sure services can be injected
  # as action arguments even if you don't extend any base controller class
  App\Controller\:
    resource: '../src/Controller'
    tags: ['controller.service_arguments']
    arguments:
      $rootPath: '%kernel.project_dir%'

  App\Controller\AuthController:
    arguments:
      $rootPath: '%kernel.project_dir%'
      $azureOpenidClientId: '%env(string:AZURE_OPENID_CLIENT_ID)%'
      $azureOpenidClientSecret: '%env(string:AZURE_OPENID_CIENT_SECRET)%'
      $azureOpenidPolicy: '%env(string:AZURE_OPENID_POLICY)%'
      $azureOpenidTenant: '%env(string:AZURE_OPENID_TENANT)%'
      $azureRedirectUri: '%env(string:AZURE_REDIRECT_URI)%'

  # add more service definitions when explicit configuration is needed
  # please note that last definitions always *replace* previous ones

  App\Security\AzureAuthenticator:
    arguments:
      $azureOpenidClientId: '%env(string:AZURE_OPENID_CLIENT_ID)%'
      $azureOpenidClientSecret: '%env(string:AZURE_OPENID_CIENT_SECRET)%'
      $azureOpenidPolicy: '%env(string:AZURE_OPENID_POLICY)%'
      $azureOpenidTenant: '%env(string:AZURE_OPENID_TENANT)%'
      $azureClientId: '%env(string:AZURE_AUTHORIZATION_CLIENT_ID)%'
      $azureClientSecret: '%env(string:AZURE_AUTHORIZATION_CIENT_SECRET)%'
      $azureTenant: '%env(string:AZURE_AUTHORIZATION_TENANT)%'
      $azureRedirectUri: '%env(string:AZURE_REDIRECT_URI)%'
      $azureAllowedGroupId: '%env(string:AZURE_ALLOWED_GROUP_ID)%'
      $profilePictureFolder: '%env(string:PROFILE_PICTURE_FOLDER)%'

  App\Command\TreatImportFileCommand:
    arguments:
      $rootPath: '%kernel.project_dir%'
      $entityManager: '@doctrine.orm.entity_manager'
      $validator: '@validator'
      $priceComparisonAPI: '@App\Helper\API\PriceComparison'
      $fileHelper: '@App\Helper\Import\FileHelper'
      $productImporter: '@App\Helper\Import\ProductImporter'

  App\Command\TreatExportFileCommand:
    arguments:
      $rootPath: '%kernel.project_dir%'
      $entityManager: '@doctrine.orm.entity_manager'
      $validator: '@validator'

  App\Form\UploadPartFieldType:
    arguments:
      $entityManager: '@doctrine.orm.entity_manager'

  App\Model\CreateUserProfilePicture:
    arguments:
      $profilePictureFolder: '%env(string:PROFILE_PICTURE_FOLDER)%'

  GuzzleHttp\Client:
    autowire: true

  App\Helper\API\PriceComparison:
    arguments:
      $host: '%env(string:PRICE_COMPARISON_API_HOST_NAME)%'
      $userName: '%env(string:PRICE_COMPARISON_API_USERNAME)%'
      $password: '%env(string:PRICE_COMPARISON_API_PASSWORD)%'
  App\EventListener\AuthSubscriber:
    tags:
      - { name: kernel.event_listener, event: kernel.request }
  gedmo.listener.timestampable:
    class: Gedmo\Timestampable\TimestampableListener
    tags:
      - { name: doctrine.event_subscriber, connection: default }
    calls:
      - [setAnnotationReader, ['@annotation_reader']]

  App\Repository\ProductFieldRepositoryInterface: '@App\Repository\ProductFieldRepository'
  App\Repository\ProductRepositoryInterface: '@App\Repository\ProductRepository'
  App\Repository\UploadRepositoryInterface: '@App\Repository\UploadRepository'
  App\Helper\Import\ProductImporter:
    arguments:
      [
        '@App\Repository\ProductFieldRepository',
        '@validator',
        '@App\Repository\ProductRepository',
        '@parameter_bag',
      ]
  App\Helper\Import\ProductImporterInterface: '@App\Helper\Import\ProductImporter'
  App\Helper\Import\FileHelper:
    arguments:
      - '%kernel.project_dir%'
      - '@filesystem'
