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']

    # Enregistrement du service PaymentCompleteListener
    app.event_listener.payment_complete_listener:
        class: App\EventListener\PaymentCompleteListener
        arguments:
            $logger: '@logger'
            $kernel: '@kernel'
            $emailSender: '@sylius.email_sender'
        public: true  # Rendre le service public

    app.promotion_rule_checker.quantity_taxon:
        class: App\Promotion\Checker\Rule\QuantityTaxonRuleChecker
        tags:
            - { name: sylius.promotion_rule_checker, type: quantity_taxon, form_type: App\Form\Type\Rule\QuantityTaxonConfigurationType, label: 'intervalle de quantité de taxons' }

    app.form.type.promotion_rule.quantity_taxon_configuration:
        class: App\Form\Type\Rule\QuantityTaxonConfigurationType
        arguments:
            $taxonsToCodesTransformer: '@sylius.form.type.data_transformer.taxons_to_codes'
        tags:
            - { name: form.type }


    App\Form\Type\ProductVariantTypeExtension:
        tags:
            { name: form.type_extension, extended_type: Sylius\Bundle\ProductBundle\Form\Type\ProductVariantType }
            
    App\Service\OrderPromotionService:
        public: true

    App\Service\ProductAccessService: 
        public: true

    App\Twig\ProductAccessExtension:
        arguments:
            $productAccessService: '@App\Service\ProductAccessService'
        tags:
            - { name: twig.extension }
    App\Command\ImportOrderToVitisoftCommand:
        tags: ['console.command']

        # config/services.yaml
# config/services.yaml
    Sylius\Bundle\CoreBundle\Form\DataTransformer\TaxonsToCodesTransformer:
        alias: sylius.form.type.data_transformer.taxons_to_codes
        public: false

    # ✅ Enregistrement du formulaire de configuration
    App\Form\Type\Rule\ExcludeTaxonsConfigurationType:
        arguments:
            - '@Sylius\Bundle\CoreBundle\Form\DataTransformer\TaxonsToCodesTransformer'
        tags: [form.type]

    # ✅ Enregistrement de la règle de promotion personnalisée
    App\Promotion\Checker\Rule\ExcludeTaxonsRuleChecker:
        tags:
            - { name: sylius.promotion_rule_checker,
                type: exclude_taxons,
                label: 'Ne contient AUCUN des taxons',
                form_type: App\Form\Type\Rule\ExcludeTaxonsConfigurationType }

    App\Controller\Checkout\AddressAndShippingController:
        arguments:
            $cartContext: '@sylius.context.cart'
            $formFactory: '@form.factory'
            $orderProcessor: '@sylius.order_processing.order_processor'   # reste identique
            $entityManager: '@doctrine.orm.entity_manager'
            $stateMachineFactory: '@sm.factory'
        tags: ['controller.service_arguments']

    App\Form\Extension\ShippingMethodChoiceDiscountExtension:
        arguments:
            - '@sylius.order_processing.order_processor'
        tags:
            - { name: form.type_extension, extended_type: Sylius\Bundle\ShippingBundle\Form\Type\ShippingMethodChoiceType }


    App\Promotion\Action\ShippingFixedDiscountPromotionActionCommand:
        tags:
            - { name: sylius.promotion_action,
                type: shipping_fixed_discount,
                form_type: App\Form\Type\Action\ShippingFixedDiscountConfigurationType,
                label: 'Remise fixe expédition' }

    App\Form\Type\Action\ShippingFixedDiscountConfigurationType:
        tags: [form.type]

    App\Form\Extension\AddressPhoneRequiredTypeExtension:
        tags:
            - { name: form.type_extension, extended_type: Sylius\Bundle\AddressingBundle\Form\Type\AddressType }



parameters:
    locale: fr_FR
    sylius_refund.supported_gateways:
        - payplug
        - payplug_oney
        - payplug_bancontact
        - payplug_apple_pay
        - payplug_american_express
