<?xml version="1.0" encoding="UTF-8"?>

<!--

 This file is part of the Sylius package.

 (c) Sylius Sp. z o.o.

 For the full copyright and license information, please view the LICENSE
 file that was distributed with this source code.

-->

<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>
        <defaults public="true" />

        <service id="sylius.listener.shop_cart_blamer" class="Sylius\Bundle\ShopBundle\EventListener\ShopCartBlamerListener">
            <argument type="service" id="sylius.context.cart" />
            <argument type="service" id="sylius.section_resolver.uri_based_section_resolver" />
            <tag name="kernel.event_listener" event="sylius.user.security.implicit_login" method="onImplicitLogin" />
            <tag name="kernel.event_listener" event="security.interactive_login" method="onInteractiveLogin" />
        </service>

        <service id="sylius.listener.email_updater" class="Sylius\Bundle\ShopBundle\EventListener\CustomerEmailUpdaterListener">
            <argument type="service" id="sylius.shop_user.token_generator.email_verification" />
            <argument type="service" id="sylius.context.channel" />
            <argument type="service" id="event_dispatcher" />
            <argument type="service" id="request_stack" />
            <argument type="service" id="sylius.section_resolver.uri_based_section_resolver" />
            <argument type="service" id="security.token_storage" />
            <tag name="kernel.event_listener" event="sylius.customer.pre_update" method="eraseVerification" />
            <tag name="kernel.event_listener" event="sylius.customer.post_update" method="sendVerificationEmail" />
        </service>

        <service id="sylius.listener.shop_customer_account_sub_section_cache_control_subscriber" class="Sylius\Bundle\ShopBundle\EventListener\ShopCustomerAccountSubSectionCacheControlSubscriber">
            <argument type="service" id="sylius.section_resolver.uri_based_section_resolver" />
            <tag name="kernel.event_subscriber" event="kernel.response" />
        </service>

        <service id="sylius.listener.order_customer_ip" class="Sylius\Bundle\ShopBundle\EventListener\OrderCustomerIpListener">
            <argument type="service" id="sylius.customer_ip_assigner" />
            <argument type="service" id="request_stack" />
            <tag name="kernel.event_listener" event="sylius.order.pre_complete" method="assignCustomerIpToOrder" />
        </service>

        <service id="sylius.listener.order_complete" class="Sylius\Bundle\ShopBundle\EventListener\OrderCompleteListener">
            <argument type="service" id="sylius.mailer.order_email_manager.shop" />
            <tag name="kernel.event_listener" event="sylius.order.post_complete" method="sendConfirmationEmail" />
        </service>

        <service id="sylius.listener.user_registration" class="Sylius\Bundle\ShopBundle\EventListener\UserRegistrationListener">
            <argument type="service" id="sylius.manager.shop_user" />
            <argument type="service" id="sylius.shop_user.token_generator.email_verification" />
            <argument type="service" id="event_dispatcher" />
            <argument type="service" id="sylius.context.channel" />
            <argument type="service" id="sylius.security.user_login" />
            <argument>%sylius_shop.firewall_context_name%</argument>
            <tag name="kernel.event_listener" event="sylius.customer.post_register" method="handleUserVerification" />
        </service>

        <service id="sylius.listener.order_integrity_checker" class="Sylius\Bundle\ShopBundle\EventListener\OrderIntegrityChecker">
            <argument type="service" id="router" />
            <argument type="service" id="sylius.manager.order" />
            <argument type="service" id="Sylius\Bundle\CoreBundle\Order\Checker\OrderPromotionsIntegrityCheckerInterface" />
            <tag name="kernel.event_listener" event="sylius.order.pre_complete" method="check" />
        </service>
        <service id="Sylius\Bundle\ShopBundle\EventListener\OrderIntegrityCheckerInterface" alias="sylius.listener.order_integrity_checker" />

        <service id="sylius.order_locale_assigner" class="Sylius\Bundle\ShopBundle\EventListener\OrderLocaleAssigner">
            <argument type="service" id="sylius.context.locale" />
            <tag name="kernel.event_listener" event="sylius.order.pre_complete" method="assignLocale" />
        </service>

        <service id="sylius.listener.session_cart" class="Sylius\Bundle\ShopBundle\EventListener\SessionCartSubscriber">
            <argument type="service" id="sylius.context.cart" />
            <argument type="service" id="sylius.storage.cart_session" />
            <tag name="kernel.event_subscriber" />
        </service>

        <service id="sylius.listener.user_cart_recalculation" class="Sylius\Bundle\ShopBundle\EventListener\UserCartRecalculationListener">
            <argument type="service" id="sylius.context.cart" />
            <argument type="service" id="sylius.order_processing.order_processor" />
            <argument type="service" id="sylius.section_resolver.uri_based_section_resolver" />
            <tag name="kernel.event_listener" event="sylius.user.security.implicit_login" method="recalculateCartWhileLogin" />
            <tag name="kernel.event_listener" event="security.interactive_login" method="recalculateCartWhileLogin" />
        </service>

        <service id="sylius.listener.user_impersonated" class="Sylius\Bundle\ShopBundle\EventListener\UserImpersonatedListener">
            <argument type="service" id="sylius.storage.cart_session" />
            <argument type="service" id="sylius.context.channel" />
            <argument type="service" id="sylius.repository.order" />
            <tag name="kernel.event_listener" event="sylius.user.security.impersonate" method="onUserImpersonated" />
        </service>
    </services>
</container>
