parameters:
    erp_api_base_url: '%env(ERP_API_BASE_URL)%'
    erp_api_key: '%env(ERP_API_KEY)%'
    app_url: '%env(APP_URL)%'
    sylius.security.new_api_shop_regex: '^/api/v2/shop'
    sylius.security.new_api_shop_route: '/api/v2/shop'
    
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

        # Allows optimizing the container by removing unused services; this also means
        # fetching services directly from the container via $container->get() won't work
        public: false

    _instanceof:
        Sylius\Bundle\ResourceBundle\Controller\ResourceController:
            autowire: false
        Sylius\Bundle\ResourceBundle\Form\Type\AbstractResourceType:
            autowire: false

    # 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/{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\Controller\:
        resource: '../src/Controller'
        tags: ['controller.service_arguments']

# Services pour la gestion des commandes
    App\Controller\Shop\OrderItemController:
        arguments:
            $cartContext: '@sylius.context.cart'
            $orderItemQuantityModifier: '@sylius.order_item_quantity_modifier'
            $orderRepository: '@sylius.repository.order'
            $productVariantRepository: '@sylius.repository.product_variant'
            $orderItemFactory: '@sylius.factory.order_item'
            $channelContext: '@sylius.context.channel'
            $csrfTokenManager: '@security.csrf.token_manager'
            $urlGenerator: '@router'
            $security: '@security.helper'
            $channelPricingController: '@App\Controller\Shop\CustomChannelPricingController'
        tags: ['controller.service_arguments']
    
    App\Controller\Shop\CartController:
        tags: ['controller.service_arguments']
    
    App\Controller\Shop\CustomOrderController:
        tags: ['controller.service_arguments']   
        
# Services pour la ShoppingList
    App\Entity\ShoppingList:
            tags: [ 'sylius.resource' ]
            
    App\Controller\Shop\ShoppingListController:
        tags: ['controller.service_arguments']    
        
    App\Repository\ShoppingListRepository:
        autowire: true
        autoconfigure: true
        
    App\Repository\CustomOrderRepository:
        parent: 'sylius.repository.order'
        
    App\Repository\CustomerHabitRepository:
        autowire: true
        autoconfigure: true    
        
    App\Controller\Shop\CustomCheckoutController:
        autowire: true
        autoconfigure: true
        
    Sylius\Bundle\OrderBundle\NumberGenerator\OrderNumberGeneratorInterface:
        alias: sylius.sequential_order_number_generator
        
    App\Service\CustomerHabitManager: ~
    
    App\Service\CustomerAuthManager: ~
   
    App\EventListener\CustomOrderCompleteListener:
        arguments:
            $habitManager: '@App\Service\CustomerHabitManager'
        tags:
            - { name: 'kernel.event_listener', event: 'app.custom_order_complete', method: 'onOrderComplete' }  
                
    app.listener.erp_commande_order_completion:
        class: App\EventListener\ErpCommandeOrderCompletionListener
        arguments:
            - '@doctrine.orm.entity_manager'
            - '@monolog.logger'
        tags:
            - { name: 'kernel.event_listener', event: 'app.custom_order_complete', method: 'onOrderCompleted' }
    
    App\Service\:
        resource: '../src/Service'
        autowire: true
        autoconfigure: true
        
    App\Twig\GlobalVariableExtension:
        tags: [ 'twig.extension' ]
        
    App\Service\ErpApi\ErpBaseService:
        autowire: true
        autoconfigure: true
        arguments:
            $client: '@http_client'
            $erpBaseUrl: '%erp_api_base_url%'
            $apiKey: '%erp_api_key%'
            $entityManager: '@doctrine.orm.entity_manager'
            $logFailedService: '@App\Service\ErpApi\LogFailedService'
            
    sylius.shop_user_provider.username_based:
        class: Sylius\Bundle\UserBundle\Provider\UsernameProvider
        arguments:
            $userRepository: '@sylius.repository.shop_user'
            $supportedUserClass: 'Sylius\Component\User\Model\UserInterface'
            
    App\EventSubscriber\RepresentativeLoginSubscriber:
        tags:
            - { name: kernel.event_subscriber }        
            
    App\Service\ErpApi\ErpTiersService:
        parent: App\Service\ErpApi\ErpBaseService
        
    App\Service\ErpApi\ErpFamilleTiersService:
        parent: App\Service\ErpApi\ErpBaseService
        
    App\Service\ErpApi\ErpArticleService:
        parent: App\Service\ErpApi\ErpBaseService
        
    App\Service\ErpApi\ErpTarifService:
        parent: App\Service\ErpApi\ErpBaseService
        
    App\Service\ErpApi\ErpTarifClientService:
        parent: App\Service\ErpApi\ErpBaseService
        
    App\Service\ErpApi\ErpAdresseService:
        parent: App\Service\ErpApi\ErpBaseService
        
    App\Service\ErpApi\ErpCommandeService:
        parent: App\Service\ErpApi\ErpBaseService
        
    App\Service\ErpApi\ErpEncoursService:
        parent: App\Service\ErpApi\ErpBaseService
        
    App\EventListener\ErpEntitySubscriber:
        arguments:
            $erpArticleService: '@App\Service\ErpApi\ErpArticleService'
            $erpFamilleTiersService: '@App\Service\ErpApi\ErpFamilleTiersService'
            $erpTarifService: '@App\Service\ErpApi\ErpTarifService'
            $erpTiersService: '@App\Service\ErpApi\ErpTiersService'
            $erpCommandeService: '@App\Service\ErpApi\ErpCommandeService'
            $erpAdresseService: '@App\Service\ErpApi\ErpAdresseService'
        tags:
            - { name: doctrine.event_subscriber }
            
    App\EventListener\MustChangePasswordListener:
        arguments:
            $security: '@security.helper'
            $entityManager: '@doctrine.orm.entity_manager'
        tags:
            - { name: kernel.event_listener, event: kernel.request, priority: 0  }
            - { name: kernel.event_listener, event: sylius.user.post_password_change, method: onPasswordChange }
    
    App\EventListener\CustomerRegistrationListener:
        tags:
            - { name: kernel.event_listener, event: sylius.customer.post_register, method: onCustomerRegistration }
           
    App\Repository\ProductFieldParameterRepository:
        arguments:
            $registry: '@doctrine'
            
    App\Security\CustomAuthenticationSuccessHandler:
        arguments:
            $router: '@router'
        
    app.listener.admin.menu_builder:
        class: App\Menu\AdminMenuListener
        tags:
            - { name: kernel.event_listener, event: sylius.menu.admin.main, method: addAdminMenuItems }

    Liip\ImagineBundle\Service\FilterService: '@liip_imagine.service.filter'
        
    App\Admin\Dashboard\CustomSalesDataProvider:
        autowire: true
        autoconfigure: true

    Sylius\Component\Core\Dashboard\SalesDataProviderInterface: '@App\Service\Admin\Dashboard\CustomSalesDataProvider'
        
    App\Admin\Dashboard\Core\CustomDashboardStatisticsProvider:
        autowire: true
        autoconfigure: true
    
    Sylius\Component\Core\Dashboard\DashboardStatisticsProviderInterface: '@App\Service\Admin\Core\Dashboard\CustomDashboardStatisticsProvider'
    
    App\MessageHandler\SendEmailMessageHandler:
        arguments:
            $projectDir: '%kernel.project_dir%'
            
    App\Service\SearchTermManager: ~

        

