<?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="Shopware\Core\Framework\Webhook\WebhookDispatcher" decorates="event_dispatcher"
                 decoration-priority="100">
            <argument type="service" id="Shopware\Core\Framework\Webhook\WebhookDispatcher.inner"/>
            <argument type="service" id="Doctrine\DBAL\Connection"/>
            <argument type="service" id="shopware.app_system.guzzle"/>
            <argument type="string">%env(APP_URL)%</argument>
            <argument type="service" id="service_container"/>
            <argument type="service" id="Shopware\Core\Framework\Webhook\Hookable\HookableEventFactory"/>
            <argument>%kernel.shopware_version%</argument>
            <argument type="service" id="Symfony\Component\Messenger\MessageBusInterface"/>
            <argument>%shopware.admin_worker.enable_admin_worker%</argument>
        </service>

        <service id="Shopware\Core\Framework\Webhook\WebhookCacheClearer">
            <argument type="service" id="Shopware\Core\Framework\Webhook\WebhookDispatcher"/>

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

        <service id="Shopware\Core\Framework\Webhook\Hookable\HookableEventFactory" lazy="true">
            <argument type="service" id="Shopware\Core\Framework\Webhook\BusinessEventEncoder"/>
            <argument type="service" id="Shopware\Core\Framework\Webhook\Hookable\WriteResultMerger"/>
        </service>

        <service id="Shopware\Core\Framework\Webhook\Hookable\WriteResultMerger">
            <argument type="service" id="Shopware\Core\Framework\DataAbstractionLayer\DefinitionInstanceRegistry"/>
        </service>

        <service id="Shopware\Core\Framework\Webhook\BusinessEventEncoder">
            <argument type="service" id="Shopware\Core\Framework\Api\Serializer\JsonEntityEncoder"/>
            <argument type="service" id="Shopware\Core\Framework\DataAbstractionLayer\DefinitionInstanceRegistry"/>
        </service>

        <service id="Shopware\Core\Framework\Webhook\WebhookDefinition">
            <tag name="shopware.entity.definition"/>
        </service>

        <service id="Shopware\Core\Framework\Webhook\EventLog\WebhookEventLogDefinition">
            <tag name="shopware.entity.definition"/>
        </service>

        <service id="Shopware\Core\Framework\Webhook\Hookable\HookableEventCollector">
            <argument type="service" id="Shopware\Core\Framework\Event\BusinessEventCollector"/>
            <argument type="service" id="Shopware\Core\Framework\DataAbstractionLayer\DefinitionInstanceRegistry"/>
        </service>

        <service id="Shopware\Core\Framework\Webhook\Handler\WebhookEventMessageHandler">
            <argument type="service" id="shopware.app_system.guzzle"/>
            <argument type="service" id="webhook.repository"/>
            <argument type="service" id="webhook_event_log.repository"/>

            <tag name="messenger.message_handler"/>
        </service>

        <service id="Shopware\Core\Framework\Webhook\Subscriber\RetryWebhookMessageFailedSubscriber">
            <argument type="service" id="webhook.repository"/>
            <argument type="service" id="webhook_event_log.repository"/>

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

        <service id="Shopware\Core\Framework\Webhook\Service\WebhookCleanup">
            <argument type="service" id="Shopware\Core\System\SystemConfig\SystemConfigService" />
            <argument type="service" id="Doctrine\DBAL\Connection" />
        </service>

        <service id="Shopware\Core\Framework\Webhook\ScheduledTask\CleanupWebhookEventLogTask">
            <tag name="shopware.scheduled.task" />
        </service>

        <service id="Shopware\Core\Framework\Webhook\ScheduledTask\CleanupWebhookEventLogTaskHandler">
            <argument type="service" id="scheduled_task.repository"/>
            <argument type="service" id="logger"/>
            <argument type="service" id="Shopware\Core\Framework\Webhook\Service\WebhookCleanup"/>
            <tag name="messenger.message_handler"/>
        </service>
    </services>
</container>
