# 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:
  timezone: '%env(APP_TIMEZONE)%'
  app.mailer_dsn: '%env(MAILER_DSN)%'
  app.mailer_mail: '%env(MAILER_MAIL)%'
  app.free_delivery_amount: '%env(FREE_DELIVERY_AMOUNT)%'
  app.under_construction: '%env(UNDER_CONSTRUCTION)%'
  uploads_base_url: '%env(APP_URL)%/uploads'
  images.base_dir: '%kernel.project_dir%/public/images'
  images.thumb_square_dir: '%kernel.project_dir%/public/images/280-280'
  images.thumb_vertical_dir: '%kernel.project_dir%/public/images/300-400'
  sms.provider: '%env(SMS_PROVIDER)%'
  sms.from: '%env(SMS_FROM)%'
  sms.sid: '%env(TWILIO_SID)%'
  sms.token: '%env(TWILIO_TOKEN)%'
  mercure_env_default: ''
  app.mercure_url: '%env(default:mercure_env_default:string:MERCURE_URL)%'
  app.mercure_public_url: '%env(default:mercure_env_default:string:MERCURE_PUBLIC_URL)%'
  app.mercure_jwt_secret: '%env(default:mercure_env_default:string:MERCURE_JWT_SECRET)%'
  app.internal_messenger_retention_days_default: '%env(int:CRM_INTERNAL_MESSENGER_RETENTION_DAYS_DEFAULT)%'
  app.doctrine_slow_query_threshold_ms: 200


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.
    App\Twig\AppExtension:
        tags: ['twig.extension']
    # 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/'
    App\Service\SmsService:
        arguments:
            $provider: '%sms.provider%'
            $from: '%sms.from%'
            $sid: '%sms.sid%'
            $token: '%sms.token%'

    App\Service\ProductImageManagerService:
        arguments:
          $imagesBaseDir: '%images.base_dir%'
          $imagesThumbSquareDir: '%images.thumb_square_dir%'
          $imagesThumbVerticalDir: '%images.thumb_vertical_dir%'

    App\Service\InternalMessengerSettingsService:
        arguments:
          $defaultRetentionDays: '%app.internal_messenger_retention_days_default%'

    App\Service\InternalMessengerMercurePublisher:
        arguments:
          $mercureUrl: '%app.mercure_url%'
          $mercurePublicUrl: '%app.mercure_public_url%'
          $mercureJwtSecret: '%app.mercure_jwt_secret%'

    App\Doctrine\Logging\SlowQuerySqlLogger:
        arguments:
          $logger: '@monolog.logger.slow_query'
          $thresholdMs: '%app.doctrine_slow_query_threshold_ms%'

    App\Command\ConfigureMercureCommand:
        arguments:
          $projectDir: '%kernel.project_dir%'

    App\Twig\CustomTwigEnvironment:
        arguments:
          - '@twig'
          - ['@Twig\Extra\String\StringExtension']

    App\EventListener\CustomLogoutListener:
        tags:
            - name: 'kernel.event_listener'
              event: 'Symfony\Component\Security\Http\Event\LogoutEvent'
              dispatcher: security.event_dispatcher.main
  # 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' ]

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

    global.variables:
      class: App\Service\GlobalVariables
twig:
    globals:
        websiteSettingService: '@App\Service\WebsiteSettingService'
        internalMessengerMercurePublicUrl: '%app.mercure_public_url%'
#    arguments:
#        $mailerDsn: '%app.mailer_dsn%'
#        $mailerMail: '%app.mailer_mail%'
