# 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:
    locale: 'en'
    # This parameter defines the codes of the locales (languages) enabled in the application
    app_locales: en|fr|de|es|cs|nl|ru|uk|ro|pt_BR|pl|it|ja|id|ca|sl|hr|zh_CN
    app.notifications.email_sender: anonymous@example.com
    base.data.folder: C:/Users/stefa/Documents/lavori/consite/ctprj/web/public-resources/
    env(MAILER_URL): =smtp://smtps.aruba.it:465?encryption=ssl&auth_mode=login&username=info@boriani.eu&password=.Stb12345@
    account.security_listener.class: App\EventListener\SecurityListener
    avatar_directory: '%kernel.project_dir%/public/upload/avatars'
    container_folder: '%kernel.project_dir%/public/upload/container'
    avatar_path: 'upload/avatars'
    logo_directory: '%kernel.project_dir%/public/upload/loghi'
    logo_path: 'upload/loghi'
    app.encryption_key: '%env(APP_ENCRYPTION_KEY)%'
    mqtt_host: '%env(MQTT_HOST)%'
    mqtt_port: '%env(int:MQTT_PORT)%'
    mqtt_username: '%env(MQTT_USERNAME)%'
    mqtt_password: '%env(MQTT_PASSWORD)%'     
    c4rgo_service.url: '%env(C4RGO_SERVICE_URL)%'
    c4rgo_service.timeout: '%env(int:C4RGO_SERVICE_TIMEOUT)%'    

services:
    # default configuration for services in *this* file
    _defaults:
        # automatically injects dependencies in your services
        autowire: true
        # automatically registers your services as commands, event subscribers, etc.
        autoconfigure: true
        # this means you cannot fetch services directly from the container via $container->get()
        # if you need to do this, you can override this setting on individual services
        public: false
        # defines the scalar arguments once and apply them to any service defined/created in this file
        bind:
            $locales: '%app_locales%'
            $defaultLocale: '%locale%'
            $emailSender: '%app.notifications.email_sender%'

    # 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/*'
        # you can exclude directories or files
        # but if a service is unused, it's removed anyway
        exclude: '../src/{Entity,Migrations,Tests}'

    # when the service definition only contains arguments, you can omit the
    # 'arguments' key and define the arguments just below the service class
    App\EventSubscriber\CommentNotificationSubscriber:
        $sender: '%app.notifications.email_sender%'
    
    sensio_framework_extra.view.listener:
        alias: Sensio\Bundle\FrameworkExtraBundle\EventListener\TemplateListener

    barcodevalidator.service:
        class: App\Utils\BarcodeValidator
        arguments: [ "@doctrine.orm.entity_manager" ]
        
    account.security_listener:
        class: '%account.security_listener.class%'
        arguments: ['@security.token_storage']
        tags:
            - { name: kernel.event_listener, event: security.interactive_login, method: onSecurityInteractiveLogin }
            
    authentication.success.listener:
        class: App\EventListener\AuthenticationEventListener
        arguments: ['@router', '@security.token_storage', '@security.authorization_checker', '@service_container']
#    authentication.failure.listener:
#        class: App\EventListener\AuthenticationEventListenerFailure
#        arguments: ['@router', '@security.token_storage', '@security.authorization_checker', '@service_container']

    app.gt.ajax.authentication.listener:
        class: App\EventListener\AjaxAuthenticationListener
        tags:
            - { name: kernel.event_listener, event: kernel.exception, method: onCoreException, priority: 1000 }  
# Configura esplicitamente il servizio di crittografia
    App\Services\EncryptionService:
        arguments:
            $params: '@parameter_bag'
            $logger: '@logger'                
# Configurazione del validator personalizzato
    App\Validator\UniqueDecodeKeyValidator:
        arguments:
            $decodeRepository: '@App\Repository\DecodeRepository'
        tags:
            - { name: validator.constraint_validator }
# Configurazione del repository con Security
    App\Repository\DecodeRepository:
        arguments:
            $registry: '@doctrine'
            $security: '@security.helper'
        tags:
            - { name: doctrine.repository_service }        

# ============================================
# .env - Variabili da aggiungere per la configurazione MQTT
# ============================================
# MQTT_HOST=127.0.0.1
# MQTT_PORT=1883
# MQTT_USERNAME=symfony_app
# MQTT_PASSWORD=your_password
# ============================================
    App\Services\SIM7600Service:
        arguments:
            $mqttHost: '%mqtt_host%'
            $mqttPort: '%mqtt_port%'
            $mqttUsername: '%mqtt_username%'
            $mqttPassword: '%mqtt_password%'
        public: true
    # Command Listener - con arguments espliciti
    App\Command\Sim7600MqttListenerCommand:
        arguments:
            $mqttHost: '%mqtt_host%'
            $mqttPort: '%mqtt_port%'
            $mqttUsername: '%mqtt_username%'
            $mqttPassword: '%mqtt_password%'
        tags:
            - { name: 'console.command' }    
    App\Services\C4rgoServiceClient:
        arguments:
            $c4rgoServiceUrl: '%c4rgo_service.url%'
            $timeout: '%c4rgo_service.timeout%'
            $logger: '@logger'       

    App\Twig\AssetVersionExtension:
        arguments:
            $projectDir: '%kernel.project_dir%'
            $packages: '@assets.packages'
            $useContentHash: false
        tags: ['twig.extension']                        
# Alias per Doctrine ObjectManager (risolve errore autowiring)
    Doctrine\Persistence\ObjectManager: '@doctrine.orm.default_entity_manager'
    Doctrine\Common\Persistence\ObjectManager: '@doctrine.orm.default_entity_manager'            
    Doctrine\Common\Persistence\ManagerRegistry: '@doctrine'
    Doctrine\Persistence\ManagerRegistry: '@doctrine'    