# 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:
# define databse connection here if the api is deployed to external servers
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: true

  # 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,DTO,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\Core\EventListener\AnnotationListener:
    tags:
      - { name: kernel.event_listener, event: kernel.controller, method: onKernelController }

  App\Core\EventSubscriber\RequestSubscriber:
    tags:
      - { name: kernel.event_listener, event: kernel.controller }

  App\Core\EventSubscriber\ResponseSubscriber:
    tags:
      - { name: kernel.event_listener, event: kernel.response }

  App\Core\EventListener\RequestListener:
    tags:
      - { name: kernel.event_listener, event: kernel.request, priority: 1 }

  App\Core\EventSubscriber\ExceptionSubscriber:
    tags:
      - { name: kernel.event_listener, event: kernel.exception }

  App\Core\Metrics\MyMetricsCollector:
    tags:
      - { name: prometheus_metrics_bundle.metrics_generator }

  App\Booking\EventListener\BookingDatabaseListener:
    tags:
      - name: 'doctrine.orm.entity_listener'
        # this is the only required option for the lifecycle listener tag
        event: 'postRemove'
        entity: 'App\Booking\Entity\Booking'
        # listeners can define their priority in case multiple listeners are associated
        # to the same event (default priority = 0; higher numbers = listener is run earlier)
        priority: 500
      - name: 'doctrine.orm.entity_listener'
        # this is the only required option for the lifecycle listener tag
        event: 'postUpdate'
        entity: 'App\Booking\Entity\Booking'
        # listeners can define their priority in case multiple listeners are associated
        # to the same event (default priority = 0; higher numbers = listener is run earlier)
        priority: 500
      - name: 'doctrine.orm.entity_listener'
        # this is the only required option for the lifecycle listener tag
        event: 'postLoad'
        entity: 'App\Booking\Entity\Booking'
        # listeners can define their priority in case multiple listeners are associated
        # to the same event (default priority = 0; higher numbers = listener is run earlier)
        priority: 500
      - name: 'doctrine.orm.entity_listener'
        # this is the only required option for the lifecycle listener tag
        event: 'prePersist'
        entity: 'App\Booking\Entity\Booking'
        # listeners can define their priority in case multiple listeners are associated
        # to the same event (default priority = 0; higher numbers = listener is run earlier)
        priority: 500
      - name: 'doctrine.orm.entity_listener'
        # this is the only required option for the lifecycle listener tag
        event: 'preUpdate'
        entity: 'App\Booking\Entity\Booking'
        # listeners can define their priority in case multiple listeners are associated
        # to the same event (default priority = 0; higher numbers = listener is run earlier)
        priority: 500
      - name: 'doctrine.orm.entity_listener'
        # this is the only required option for the lifecycle listener tag
        event: 'postFlush'
        entity: 'App\Booking\Entity\Booking'
        # listeners can define their priority in case multiple listeners are associated
        # to the same event (default priority = 0; higher numbers = listener is run earlier)
        priority: 500
      - name: 'doctrine.orm.entity_listener'
        # this is the only required option for the lifecycle listener tag
        event: 'onFlush'
        entity: 'App\Booking\Entity\Booking'
        # listeners can define their priority in case multiple listeners are associated
        # to the same event (default priority = 0; higher numbers = listener is run earlier)
        priority: 500

  App\Customer\EventListener\CustomerCreateListener:
    tags:
      - name: 'doctrine.orm.entity_listener'
        # this is the only required option for the lifecycle listener tag
        event: 'prePersist'
        entity: 'App\Customer\Entity\Customer'
        # listeners can define their priority in case multiple listeners are associated
        # to the same event (default priority = 0; higher numbers = listener is run earlier)
        priority: 500
      - name: 'doctrine.orm.entity_listener'
        # this is the only required option for the lifecycle listener tag
        entity: 'App\Customer\Entity\Customer'
        event: 'postFlush'
        # listeners can define their priority in case multiple listeners are associated
        # to the same event (default priority = 0; higher numbers = listener is run earlier)
        priority: 500
      - name: 'doctrine.orm.entity_listener'
        # this is the only required option for the lifecycle listener tag
        event: 'onFlush'
        entity: 'App\Customer\Entity\Customer'
        # listeners can define their priority in case multiple listeners are associated
        # to the same event (default priority = 0; higher numbers = listener is run earlier)
        priority: 500
      - name: 'doctrine.orm.entity_listener'
        # this is the only required option for the lifecycle listener tag
        event: 'postLoad'
        entity: 'App\Customer\Entity\Customer'
        # listeners can define their priority in case multiple listeners are associated
        # to the same event (default priority = 0; higher numbers = listener is run earlier)
        priority: 500
        # this is the only required option for the lifecycle listener tag

  App\Price\EventListener\InvoicePositionDatabaseListener:
    tags:
      - name: 'doctrine.orm.entity_listener'
        # this is the only required option for the lifecycle listener tag
        event: 'postLoad'
        entity: 'App\Price\Entity\InvoicePosition'
        # listeners can define their priority in case multiple listeners are associated
        # to the same event (default priority = 0; higher numbers = listener is run earlier)
        priority: 500

  App\Configuration\EventListener\InputFieldDatabaseListener:
    tags:
      - name: 'doctrine.orm.entity_listener'
        # this is the only required option for the lifecycle listener tag
        event: 'postLoad'
        entity: 'App\Configuration\Entity\InputField'
        # listeners can define their priority in case multiple listeners are associated
        # to the same event (default priority = 0; higher numbers = listener is run earlier)
        priority: 500

  App\VehicleGroup\EventListener\GroupDatabaseListener:
    tags:
      - name: 'doctrine.orm.entity_listener'
        # this is the only required option for the lifecycle listener tag
        event: 'postLoad'
        entity: 'App\VehicleGroup\Entity\Group'
        # listeners can define their priority in case multiple listeners are associated
        # to the same event (default priority = 0; higher numbers = listener is run earlier)
        priority: 500

  App\Core\DBAL\ConnectionWrapper: '@doctrine.dbal.default_connection'

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