# 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.flag_dir: "web/flags"

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"

  api.event.jwt_created_listener:
    class: App\EventListener\JWTCreatedListener
    arguments: ["@request_stack"]
    tags:
      - { name: kernel.event_listener, event: lexik_jwt_authentication.on_jwt_created, method: onJWTCreated }

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

  app.listener.authentication_success_response:
    class: App\EventListener\AuthenticationSuccessListener
    arguments: ["@lexik_jwt_authentication.jwt_manager"]
    tags:
      - { name: kernel.event_listener, event: lexik_jwt_authentication.handler.authentication_success, method: onAuthenticationSuccessResponse }

  App\EventSubscriber\ExceptionSubscriber:
    tags:
      - { name: kernel.event_subscriber }

  # Definición de servicios
  App\Service\DTOMapperService: ~
  App\Service\MaincompanyService: ~
  App\Service\UserService: ~
  App\Service\CarrierService: ~
  App\Service\CountryService: ~

  App\Service\GuideService: ~
  App\Service\WarehouseReceiptService: ~

  App\Service\ReceiptService:
    arguments:
      $serviceLocator: '@service_locator.guide_warehouse'
      
  App\Service\ReempackService:
    arguments:
        $serviceLocator: '@service_locator.guide_warehouse'

  # Service Locator para GuideService y WarehouseReceiptService
  service_locator.guide_warehouse:
    class: Symfony\Component\DependencyInjection\ServiceLocator
    arguments:
      -
        App\Service\GuideService: '@App\Service\GuideService'
        App\Service\WarehouseReceiptService: '@App\Service\WarehouseReceiptService'
        App\Service\ConsolidatedService: '@App\Service\ConsolidatedService'

  # Voters
  App\Security\Voter\:
    resource: "../src/Security/Voter/*"
    tags: ["security.voter"]

  # Add the LocaleListener service
  App\EventListener\LocaleListener:
    arguments:
      $security: '@security.helper'  # Inject the security service (use '@security.token_storage' if needed)
      $translator: '@translator'
      $defaultLocale: 'en'  # Set the default locale (you can adjust this if necessary)
    tags:
      - { name: kernel.event_listener, event: kernel.request, method: onKernelRequest }

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