<?xml version="1.0" ?>

<container xmlns="http://symfony.com/schema/dic/services"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">

    <services>

        <!-- DAL DEFINITIONS + SERVICES -->
        <service id="Shopware\Core\Checkout\Promotion\PromotionDefinition">
            <tag name="shopware.entity.definition"/>
        </service>

        <service id="Shopware\Core\Checkout\Promotion\Aggregate\PromotionSalesChannel\PromotionSalesChannelDefinition">
            <tag name="shopware.entity.definition"/>
        </service>

        <service id="Shopware\Core\Checkout\Promotion\Aggregate\PromotionIndividualCode\PromotionIndividualCodeDefinition">
            <tag name="shopware.entity.definition"/>
        </service>

        <service id="Shopware\Core\Checkout\Promotion\Aggregate\PromotionDiscount\PromotionDiscountDefinition">
            <tag name="shopware.entity.definition"/>
        </service>

        <service id="Shopware\Core\Checkout\Promotion\Aggregate\PromotionDiscountRule\PromotionDiscountRuleDefinition">
            <tag name="shopware.entity.definition"/>
        </service>

        <service id="Shopware\Core\Checkout\Promotion\Aggregate\PromotionSetGroup\PromotionSetGroupDefinition">
            <tag name="shopware.entity.definition"/>
        </service>

        <service id="Shopware\Core\Checkout\Promotion\Aggregate\PromotionSetGroupRule\PromotionSetGroupRuleDefinition">
            <tag name="shopware.entity.definition"/>
        </service>

        <service id="Shopware\Core\Checkout\Promotion\Aggregate\PromotionOrderRule\PromotionOrderRuleDefinition">
            <tag name="shopware.entity.definition"/>
        </service>

        <service id="Shopware\Core\Checkout\Promotion\Aggregate\PromotionPersonaCustomer\PromotionPersonaCustomerDefinition">
            <tag name="shopware.entity.definition"/>
        </service>

        <service id="Shopware\Core\Checkout\Promotion\Aggregate\PromotionPersonaRule\PromotionPersonaRuleDefinition">
            <tag name="shopware.entity.definition"/>
        </service>

        <service id="Shopware\Core\Checkout\Promotion\Aggregate\PromotionCartRule\PromotionCartRuleDefinition">
            <tag name="shopware.entity.definition"/>
        </service>

        <service id="Shopware\Core\Checkout\Promotion\Aggregate\PromotionTranslation\PromotionTranslationDefinition">
            <tag name="shopware.entity.definition"/>
        </service>

        <service id="Shopware\Core\Checkout\Promotion\Aggregate\PromotionDiscountPrice\PromotionDiscountPriceDefinition">
            <tag name="shopware.entity.definition"/>
        </service>

        <service id="Shopware\Core\Checkout\Promotion\Validator\PromotionValidator">
            <argument type="service" id="Doctrine\DBAL\Connection"/>
            <tag name="kernel.event_subscriber"/>
        </service>

        <service id="Shopware\Core\Checkout\Promotion\Cart\PromotionRedemptionLocker">
            <argument type="service" id="lock.factory"/>
            <tag name="kernel.event_subscriber"/>
        </service>

        <!-- CART CALCULATORS -->
        <service id="Shopware\Core\Checkout\Promotion\Cart\PromotionItemBuilder"/>

        <service id="Shopware\Core\Checkout\Promotion\Cart\PromotionCollector">
            <argument type="service" id="Shopware\Core\Checkout\Promotion\Gateway\PromotionGateway"/>
            <argument type="service" id="Shopware\Core\Checkout\Promotion\Cart\PromotionItemBuilder"/>
            <argument type="service" id="Shopware\Core\Framework\Util\HtmlSanitizer"/>
            <argument type="service" id="Doctrine\DBAL\Connection"/>
            <!-- // inject after product collector(5000) -->
            <tag name="shopware.cart.collector" priority="4900"/>
        </service>

        <service id="Shopware\Core\Checkout\Promotion\Cart\PromotionProcessor">
            <argument type="service" id="Shopware\Core\Checkout\Promotion\Cart\PromotionCalculator"/>
            <argument type="service" id="Shopware\Core\Checkout\Cart\LineItem\Group\LineItemGroupBuilder"/>

            <tag name="shopware.cart.processor" priority="4900"/>
        </service>

        <service id="Shopware\Core\Checkout\Promotion\Cart\PromotionDeliveryProcessor">
            <argument type="service" id="Shopware\Core\Checkout\Promotion\Cart\PromotionDeliveryCalculator"/>
            <argument type="service" id="Shopware\Core\Checkout\Cart\LineItem\Group\LineItemGroupBuilder"/>

            <tag name="shopware.cart.processor" priority="-5100"/>
        </service>

        <service id="Shopware\Core\Checkout\Promotion\Cart\PromotionCalculator">
            <argument type="service" id="Shopware\Core\Checkout\Cart\Price\AmountCalculator"/>
            <argument type="service" id="Shopware\Core\Checkout\Cart\Price\AbsolutePriceCalculator"/>
            <argument type="service" id="Shopware\Core\Checkout\Cart\LineItem\Group\LineItemGroupBuilder"/>
            <argument type="service" id="Shopware\Core\Checkout\Promotion\Cart\Discount\Composition\DiscountCompositionBuilder"/>
            <argument type="service" id="Shopware\Core\Checkout\Promotion\Cart\Discount\Filter\AdvancedPackageFilter"/>
            <argument type="service" id="Shopware\Core\Checkout\Promotion\Cart\Discount\Filter\AdvancedPackagePicker"/>
            <argument type="service" id="Shopware\Core\Checkout\Promotion\Cart\Discount\Filter\AdvancedPackageRules"/>
            <argument type="service" id="Shopware\Core\Checkout\Cart\LineItem\LineItemQuantitySplitter"/>
            <argument type="service" id="Shopware\Core\Checkout\Cart\Price\PercentagePriceCalculator"/>
            <argument type="service" id="Shopware\Core\Checkout\Promotion\Cart\Discount\ScopePackager\CartScopeDiscountPackager"/>
            <argument type="service" id="Shopware\Core\Checkout\Promotion\Cart\Discount\ScopePackager\SetGroupScopeDiscountPackager"/>
            <argument type="service" id="Shopware\Core\Checkout\Promotion\Cart\Discount\ScopePackager\SetScopeDiscountPackager"/>
        </service>

        <service id="Shopware\Core\Checkout\Promotion\Cart\PromotionDeliveryCalculator">
            <argument type="service" id="Shopware\Core\Checkout\Cart\Price\QuantityPriceCalculator"/>
            <argument type="service" id="Shopware\Core\Checkout\Cart\Price\PercentagePriceCalculator"/>
            <argument type="service" id="Shopware\Core\Checkout\Promotion\Cart\PromotionItemBuilder"/>
        </service>

        <!-- SUBSCRIBERS -->
        <service id="Shopware\Core\Checkout\Promotion\Subscriber\Storefront\StorefrontCartSubscriber">
            <argument type="service" id="event_dispatcher"/>
            <argument type="service" id="request_stack"/>
            <tag name="kernel.event_subscriber"/>
        </service>

        <!-- API CONTROLLERS -->
        <service id="Shopware\Core\Checkout\Promotion\Api\PromotionActionController" public="true">
            <argument type="service" id="Shopware\Core\Checkout\Cart\LineItem\Group\LineItemGroupServiceRegistry"/>
            <argument type="service" id="Shopware\Core\Checkout\Promotion\Cart\Discount\Filter\FilterServiceRegistry"/>
            <call method="setContainer">
                <argument type="service" id="service_container"/>
            </call>
        </service>

        <service id="Shopware\Core\Checkout\Promotion\Api\PromotionController" public="true">
            <argument type="service" id="Shopware\Core\Checkout\Promotion\Util\PromotionCodeService"/>
            <call method="setContainer">
                <argument type="service" id="service_container"/>
            </call>
        </service>

        <!-- FILTER SERVICES -->
        <service id="Shopware\Core\Checkout\Promotion\Cart\Discount\Filter\AdvancedPackageFilter">
            <argument type="service" id="Shopware\Core\Checkout\Promotion\Cart\Discount\Filter\FilterServiceRegistry"/>
        </service>

        <service id="Shopware\Core\Checkout\Promotion\Cart\Discount\Filter\AdvancedPackagePicker">
            <argument type="service" id="Shopware\Core\Checkout\Promotion\Cart\Discount\Filter\FilterServiceRegistry"/>
        </service>

        <service id="Shopware\Core\Checkout\Promotion\Cart\Discount\Filter\AdvancedPackageRules">
        </service>

        <service id="Shopware\Core\Checkout\Promotion\Cart\Discount\Filter\FilterServiceRegistry">
            <argument type="tagged_iterator" tag="promotion.filter.sorter"/>
            <argument type="tagged_iterator" tag="promotion.filter.picker"/>
        </service>

        <service id="Shopware\Core\Checkout\Promotion\Cart\Discount\Filter\Sorter\FilterSorterPriceAsc">
            <tag name="promotion.filter.sorter"/>
        </service>

        <service id="Shopware\Core\Checkout\Promotion\Cart\Discount\Filter\Sorter\FilterSorterPriceDesc">
            <tag name="promotion.filter.sorter"/>
        </service>

        <service id="Shopware\Core\Checkout\Promotion\Cart\Discount\Filter\Picker\VerticalPicker">
            <tag name="promotion.filter.picker"/>
        </service>

        <service id="Shopware\Core\Checkout\Promotion\Cart\Discount\Filter\Picker\HorizontalPicker">
            <tag name="promotion.filter.picker"/>
        </service>

        <!-- ADDITIONAL SERVICES -->
        <service id="Shopware\Core\Checkout\Promotion\Gateway\PromotionGateway">
            <argument type="service" id="promotion.repository"/>
            <argument type="service" id="Shopware\Core\Checkout\Promotion\Service\PromotionDateTimeService"/>
        </service>

        <service id="Shopware\Core\Checkout\Promotion\Subscriber\PromotionIndividualCodeRedeemer">
            <argument type="service" id="promotion_individual_code.repository"/>
            <argument type="service" id="order_customer.repository"/>

            <tag name="kernel.event_subscriber"/>
        </service>

        <service id="Shopware\Core\Checkout\Promotion\Service\PromotionDateTimeService"/>

        <service id="Shopware\Core\Checkout\Promotion\Util\PromotionCodeService">
            <argument type="service" id="promotion.repository"/>
            <argument type="service" id="promotion_individual_code.repository"/>
            <argument type="service" id="Doctrine\DBAL\Connection"/>
        </service>

        <service id="Shopware\Core\Checkout\Promotion\Cart\Discount\Composition\DiscountCompositionBuilder">
        </service>

        <service id="Shopware\Core\Checkout\Promotion\DataAbstractionLayer\PromotionIndexer">
            <argument type="service" id="Shopware\Core\Framework\DataAbstractionLayer\Dbal\Common\IteratorFactory"/>
            <argument type="service" id="promotion.repository"/>
            <argument type="service" id="Shopware\Core\Checkout\Promotion\DataAbstractionLayer\PromotionExclusionUpdater"/>
            <argument type="service" id="Shopware\Core\Checkout\Promotion\DataAbstractionLayer\PromotionRedemptionUpdater"/>
            <tag name="shopware.entity_indexer"/>
            <argument type="service" id="event_dispatcher"/>
        </service>

        <service id="Shopware\Core\Checkout\Promotion\DataAbstractionLayer\PromotionRedemptionUpdater">
            <argument type="service" id="Doctrine\DBAL\Connection"/>
            <tag name="kernel.event_subscriber"/>
        </service>

        <service id="Shopware\Core\Checkout\Promotion\DataAbstractionLayer\PromotionExclusionUpdater">
            <argument type="service" id="Doctrine\DBAL\Connection"/>
        </service>

        <service id="Shopware\Core\Checkout\Promotion\Cart\Discount\ScopePackager\CartScopeDiscountPackager"/>

        <service id="Shopware\Core\Checkout\Promotion\Cart\Discount\ScopePackager\SetGroupScopeDiscountPackager">
            <argument type="service" id="Shopware\Core\Checkout\Cart\LineItem\Group\LineItemGroupBuilder"/>
        </service>

        <service id="Shopware\Core\Checkout\Promotion\Cart\Discount\ScopePackager\SetScopeDiscountPackager">
            <argument type="service" id="Shopware\Core\Checkout\Cart\LineItem\Group\LineItemGroupBuilder"/>
        </service>

        <service id="Shopware\Core\Checkout\Promotion\Cart\CartPromotionsSubscriber">
            <tag name="kernel.event_subscriber"/>
        </service>
    </services>
</container>
