# 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:
  container.dumper.inline_factories: true
  uploads_directory: '%kernel.project_dir%/public/uploads/'
  csv_directory: '%kernel.project_dir%/csv/'
  scan_directory: '%kernel.project_dir%/public/scan/'
  database_dump_directory: '%kernel.project_dir%/sql/'
  soap_directory: '%kernel.project_dir%/src/Soap/'
  app_env: '%env(APP_ENV)%'
  dms_env: '%env(DMS_ENV)%'
  iservice_env: '%env(ISERVICE_ENV)%'
  timezone: '%env(TIMEZONE)%'
  aws_appconfig_agent_host: '%env(AWS_APPCONFIG_AGENT_HOST)%'
  aws_appconfig_agent_port: '%env(AWS_APPCONFIG_AGENT_PORT)%'
  aws_appconfig_application: '%env(AWS_APPCONFIG_APPLICATION)%'
  aws_appconfig_environment: '%env(AWS_APPCONFIG_ENVIRONMENT)%'
  aws_appconfig_configuration: '%env(AWS_APPCONFIG_CONFIGURATION)%'
  mailer_dsn: 'default'
  redis_url: "redis://default:%%/l7|,UG6{Zu$H;0T15YT`32d)3aJ:J%40@localhost:6379"
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.
    public: false
    bind:
      $iserviceLogger: '@monolog.logger.iservice'
      $accessLogger: '@monolog.logger.access'
      $errorLogger: '@monolog.logger.error'
      $commandLogger: '@monolog.logger.command'
      $messengerLogger: '@monolog.logger.messenger'
      $logscaleLogger: '@monolog.logger.logscale'
  # 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'
      - '../src/Tests/'

  # 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' ]

  app.custom_authenticator:
    class: App\Security\Authenticator
    parent: lexik_jwt_authentication.security.jwt_authenticator

  usingDealerTrack:
    class: App\Service\DMS\DealerTrackClient

  usingCdk:
    class: App\Service\DMS\CDKClient

  usingDealerBuilt:
    class: App\Service\DMS\DealerBuiltClient

  usingAutomate:
    class: App\Service\DMS\AutomateClient

  usingReynolds:
    class: App\Service\DMS\ReynoldsClient

  usingGoodyear:
    class: App\Service\DMS\GoodyearClient

  #service locators
  _instanceof:
    App\Service\DMS\DMSClientInterface:
      tags:
        - { name: "dms_clients" }

#    App\Service\Payment\PaymentTypeInterface:
#      tags:
#        - { name: "payment_clients" }
    App\Service\Payment\NMI:
      tags:
        - { name: "payment_clients" }
    App\Service\Payment\HeartlandInterface:
      tags:
        - { name: "payment_clients" }
    App\Service\Payment\GlobalPay:
      tags:
        - { name: "payment_clients" }

    App\Service\Scheduler\SchedulerAvailabilityInterface:
      tags:
        - { name: "scheduler_availability_methods" }


  App\Service\DMS\DMS:
    arguments: [ !tagged_locator { tag: 'dms_clients', default_index_method: 'getDefaultIndexName' } ]

  App\Service\Payment\Payment:
    arguments: [ !tagged_locator { tag: 'payment_clients', default_index_method: 'getDefaultIndexName' } ]

  App\Service\Scheduler\Scheduler:
    arguments: [ !tagged_locator { tag: 'scheduler_availability_methods', default_index_method: 'getDefaultIndexName' } ]

  param_converter_not_found.listener:
    class: App\EventListener\ParamConverterNotFoundEventListener
    tags:
      - { name: kernel.event_listener, event: kernel.exception, method: onKernelException, priority: 200 }

  iservice_disabled_exception.listener:
    class: App\EventListener\IServiceDisabledEventListener
    tags:
      - { name: kernel.event_listener, event: kernel.exception, method: onKernelException, priority: 200 }

  command.listener:
    class: App\EventListener\CommandEventListener
    tags:
      - { name: kernel.event_listener, event: console.command, method: onConsoleCommand, priority: 200 }
      - { name: kernel.event_listener, event: console.error, method: onConsoleCommandError, priority: 200 }
      - { name: kernel.event_listener, event: console.terminate, method: onConsoleCommandTerminate, priority: 200 }

  iservice_logger.listener:
    class: App\EventListener\iServiceLoggerEventListener
    tags:
      - { name: kernel.event_listener, event: kernel.response, method: onKernelResponse, priority: 200 }

  access_logger.listener:
    class: App\EventListener\AccessLoggerEventListener
    tags:
      - { name: kernel.event_listener, event: kernel.exception, method: onKernelException, priority: 200 }

  error_logger.listener:
    class: IService\Bundle\EventListener\ErrorLoggerEventListener
    tags:
      - { name: kernel.event_listener, event: kernel.exception, method: onKernelException, priority: 200 }

  client_logger.listener:
    class: App\EventListener\ClientLoggerEventListener
    tags:
      - { name: kernel.event_listener, event: kernel.exception, method: onKernelException, priority: 200 }

  logscale_logger.listener:
    class: App\EventListener\LogScaleLoggerEventListener
    tags:
      - { name: kernel.event_listener, event: kernel.response, method: onKernelResponse, priority: 200 }
      - { name: kernel.event_listener, event: kernel.exception, method: onKernelException, priority: 200 }

  entity_post_load.listener:
    class: App\EventListener\EntityPostLoadEventListener
    tags:
      - { name: doctrine.event_listener, event: postLoad }

  monolog.formatter.iservice:
    class: App\Logger\iServiceLogFormatter

  monolog.formatter.command:
    class: App\Logger\CommandLogFormatter

  monolog.formatter.logscale:
    class: App\Logger\LogScaleLogFormatter

  App\Service\Motor\MotorServiceInterface: "@App\\Service\\Motor\\MotorService"
  App\Service\Payment\HeartlandInterface: "@App\\Service\\Payment\\Heartland"

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

  App\Enum\EventTypeEnum:
    tags: [doctrine.enum]

  App\Enum\EventEnum:
    tags: [doctrine.enum]

  App\Service\AWS\CognitoInterface:
    class: App\Service\AWS\Cognito

  jwt.exception.listener:
    class: App\EventListener\JWTExceptionListener
    tags:
      - { name: kernel.event_listener, event: lexik_jwt_authentication.on_jwt_not_found, method: onJWTNotFound }