<?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>
        <service id="RiccardoLoyalty\Core\Content\Loyalty\LoyaltyAccountDefinition">
            <tag name="shopware.entity.definition" entity="riccardo_loyalty_account"/>
        </service>
        <service id="RiccardoLoyalty\Core\Content\Loyalty\LoyaltyTransactionDefinition">
            <tag name="shopware.entity.definition" entity="riccardo_loyalty_transaction"/>
        </service>

        <service id="RiccardoLoyalty\Core\Content\Loyalty\LoyaltyConfig">
            <argument type="service" id="Shopware\Core\System\SystemConfig\SystemConfigService"/>
        </service>
        <service id="RiccardoLoyalty\Core\Content\Loyalty\CardNumberGenerator">
            <argument type="service" id="Doctrine\DBAL\Connection"/>
        </service>
        <service id="RiccardoLoyalty\Core\Content\Loyalty\LoyaltyService">
            <argument type="service" id="Doctrine\DBAL\Connection"/>
            <argument type="service" id="RiccardoLoyalty\Core\Content\Loyalty\CardNumberGenerator"/>
            <argument type="service" id="RiccardoLoyalty\Core\Content\Loyalty\LoyaltyConfig"/>
        </service>
        <service id="RiccardoLoyalty\Core\Barcode\Ean13Barcode"/>

        <service id="RiccardoLoyalty\Core\Checkout\Cart\LoyaltyCartProcessor">
            <argument type="service" id="RiccardoLoyalty\Core\Content\Loyalty\LoyaltyService"/>
            <argument type="service" id="RiccardoLoyalty\Core\Content\Loyalty\LoyaltyConfig"/>
            <argument type="service" id="Shopware\Core\Checkout\Cart\Price\AbsolutePriceCalculator"/>
            <!-- nach Produkten (5000), Deals (4950), Promotions (4900) und Custom-Positionen (4000) -->
            <tag name="shopware.cart.collector" priority="3900"/>
            <tag name="shopware.cart.processor" priority="3900"/>
        </service>

        <service id="RiccardoLoyalty\Core\Checkout\Subscriber\OrderSubscriber">
            <argument type="service" id="RiccardoLoyalty\Core\Content\Loyalty\LoyaltyService"/>
            <argument type="service" id="RiccardoLoyalty\Core\Content\Loyalty\LoyaltyConfig"/>
            <argument type="service" id="Doctrine\DBAL\Connection"/>
            <argument type="service" id="logger"/>
            <tag name="kernel.event_subscriber"/>
        </service>

        <service id="RiccardoLoyalty\Command\EnrollCustomersCommand">
            <argument type="service" id="Doctrine\DBAL\Connection"/>
            <argument type="service" id="RiccardoLoyalty\Core\Content\Loyalty\LoyaltyService"/>
            <tag name="console.command"/>
        </service>

        <service id="RiccardoLoyalty\Api\LoyaltyApiController" public="true">
            <argument type="service" id="RiccardoLoyalty\Core\Content\Loyalty\LoyaltyService"/>
            <argument type="service" id="RiccardoLoyalty\Core\Content\Loyalty\LoyaltyConfig"/>
        </service>

        <service id="RiccardoLoyalty\Storefront\Controller\LoyaltyController" public="true">
            <argument type="service" id="Shopware\Storefront\Page\GenericPageLoader"/>
            <argument type="service" id="RiccardoLoyalty\Core\Content\Loyalty\LoyaltyService"/>
            <argument type="service" id="RiccardoLoyalty\Core\Content\Loyalty\LoyaltyConfig"/>
            <argument type="service" id="Shopware\Core\Checkout\Cart\SalesChannel\CartService"/>
            <call method="setContainer"><argument type="service" id="service_container"/></call>
        </service>

        <service id="RiccardoLoyalty\Storefront\Twig\LoyaltyExtension">
            <argument type="service" id="RiccardoLoyalty\Core\Barcode\Ean13Barcode"/>
            <argument type="service" id="RiccardoLoyalty\Core\Content\Loyalty\LoyaltyConfig"/>
            <tag name="twig.extension"/>
        </service>
    </services>
</container>
