parameters:
    env(INDEX_ROBOT): 'true'
services:
    # Expose Sylius Shop ContactController as a service to allow sub-requests

    # 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,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']
        
    App\Twig\AppExtension:
        arguments:
            $indexRobot: '%env(INDEX_ROBOT)%'
        tags:
            - { name: twig.extension }

    App\Twig\VariantStatsExtension:
        tags:
            - { name: twig.extension }

    
    # Send confirmation email with first/last name and seat count after payment validation
    App\EventListener\OrderValidationListener:
        tags:
            - { name: kernel.event_listener, event: 'workflow.sylius_order_payment.completed.pay', method: sendConfirmationEmail }
        arguments:
            $adminRecipient: '%env(MAILER_RECIPIENT)%'

    App\EventListener\OrderRefundInventoryListener:
        arguments:
            $orderInventoryOperator: '@sylius.operator.inventory.order_inventory'
        tags:
            - { name: kernel.event_listener, event: 'workflow.sylius_order_payment.completed.refund', method: giveBackInventory, priority: 200 }

    # (Removed PaymentCompleteListener - no longer needed)

    App\EventSubscriber\ProductCreationSubscriber:
        tags: [ 'doctrine.orm.entity_listener' ]
        arguments:
            $variantFactory: '@sylius.factory.product_variant'
            $channelPricingFactory: '@sylius.factory.channel_pricing'
    # config/services.yaml
    
    App\Controller\Admin\VariantGeneratorController:
        arguments:
            $variantFactory: '@sylius.factory.product_variant'
            $optionFactory:  '@sylius.factory.product_option'
            $optionValueFactory: '@sylius.factory.product_option_value'
            $optionRepo:     '@sylius.repository.product_option'
            $optionValueRepo: '@sylius.repository.product_option_value'
            $variantRepo:    '@sylius.repository.product_variant'
            $productRepo:    '@sylius.repository.product'
            $channelPricingFactory: '@sylius.factory.channel_pricing'

    # alias pour l’autowiring (si bloc ci‑dessus supprimé)
    Sylius\Component\Product\Repository\ProductRepositoryInterface: '@sylius.repository.product'

    Knp\Snappy\Pdf:
        arguments:
            $binary: '%env(WKHTMLTOPDF_PATH)%'
    
    Sylius\Component\Core\Repository\ProductVariantRepositoryInterface:
        alias: 'sylius.repository.product_variant'

    App\Service\EventSessionProcessor:
        arguments:
            $sender:    '%env(MAIL_USERNAME)%'
            $recipient: '%env(MAILER_RECIPIENT)%'

    App\Shipping\Rule\ItemsTotalBetweenRuleChecker:
        tags:
            - { name: sylius.shipping_method_rule_checker, type: 'items_total_between', form_type: App\Form\Type\Shipping\Rule\ItemsTotalBetweenConfigurationType, label: 'app.form.shipping_method_rule.items_total_between' }

    sylius_shop.twig.component.product.card:
        class: App\Twig\Component\Product\CardComponent
        arguments:
            $productRepository: '@sylius.repository.product'
            $productVariantResolver: '@sylius.resolver.product_variant'
            $channelContext: '@sylius.context.channel'
            $localeContext: '@sylius.context.locale'
            $productVariantPricesCalculator: '@sylius.calculator.product_variant_price'
        tags:
            - { name: sylius.twig_component, key: 'sylius_shop:product:card' }
