<?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>
        <!-- Template Entities -->
        <service id="Shopware\Core\Content\MailTemplate\MailTemplateDefinition">
            <tag name="shopware.entity.definition"  entity="mail_template"/>
        </service>

        <service id="Shopware\Core\Content\MailTemplate\Aggregate\MailTemplateTranslation\MailTemplateTranslationDefinition">
            <tag name="shopware.entity.definition"  entity="mail_template_translation"/>
        </service>

        <service id="Shopware\Core\Content\MailTemplate\Aggregate\MailTemplateType\MailTemplateTypeDefinition">
            <tag name="shopware.entity.definition"  entity="mail_template_type"/>
        </service>

        <service id="Shopware\Core\Content\MailTemplate\Aggregate\MailTemplateTypeTranslation\MailTemplateTypeTranslationDefinition">
            <tag name="shopware.entity.definition"  entity="mail_template_type_translation"/>
        </service>

        <service id="Shopware\Core\Content\MailTemplate\Aggregate\MailTemplateMedia\MailTemplateMediaDefinition">
            <tag name="shopware.entity.definition"/>
        </service>

        <!-- Header Footer Entities -->
        <service id="Shopware\Core\Content\MailTemplate\Aggregate\MailHeaderFooter\MailHeaderFooterDefinition">
            <tag name="shopware.entity.definition"/>
        </service>

        <service id="Shopware\Core\Content\MailTemplate\Aggregate\MailHeaderFooterTranslation\MailHeaderFooterTranslationDefinition">
            <tag name="shopware.entity.definition"/>
        </service>

        <!-- Controller -->
        <service id="Shopware\Core\Content\MailTemplate\Api\MailActionController" public="true">
            <argument type="service" id="Shopware\Core\Content\Mail\Service\MailService"/>
            <argument type="service" id="Shopware\Core\Framework\Adapter\Twig\StringTemplateRenderer"/>
            <call method="setContainer">
                <argument type="service" id="service_container"/>
            </call>
        </service>

        <!-- Sending -->
        <service id="Shopware\Core\Content\Mail\Message\SendMailHandler">
            <argument type="service" id="mailer.transports"/>
            <argument type="service" id="shopware.filesystem.private"/>
            <argument type="service" id="logger"/>
            <tag name="messenger.message_handler"/>
        </service>

        <service id="Shopware\Core\Content\Mail\Service\MailSender" public="true">
            <argument type="service" id="mailer.mailer"/>
            <argument type="service" id="shopware.filesystem.private"/>
            <argument type="service" id="Shopware\Core\System\SystemConfig\SystemConfigService"/>
            <argument>%shopware.mail.max_body_length%</argument>
            <argument type="service" id="logger"/>
            <argument type="abstract" id="message bus"/>
        </service>

        <service id="Shopware\Core\Content\Mail\Service\MailFactory" public="true">
            <argument type="service" id="validator"/>
        </service>

        <service id="Shopware\Core\Content\Mail\Service\MailService">
            <argument type="service" id="Shopware\Core\Framework\Validation\DataValidator" />
            <argument type="service" id="Shopware\Core\Framework\Adapter\Twig\StringTemplateRenderer" />
            <argument type="service" id="Shopware\Core\Content\Mail\Service\MailFactory" />
            <argument type="service" id="Shopware\Core\Content\Mail\Service\MailSender" />
            <argument type="service" id="media.repository" />
            <argument type="service" id="sales_channel.repository"/>
            <argument type="service" id="Shopware\Core\System\SystemConfig\SystemConfigService"/>
            <argument type="service" id="event_dispatcher"/>
            <argument type="service" id="logger"/>
            <argument type="service" id="Shopware\Core\System\Locale\LanguageLocaleCodeProvider"/>
        </service>

        <service id="Shopware\Core\Content\Mail\Service\SendMailTemplate">
            <argument type="service" id="Shopware\Core\Content\Mail\Service\MailService"/>
            <argument type="service" id="mail_template.repository"/>
            <argument type="service" id="logger"/>
            <argument type="service" id="Shopware\Core\Framework\Adapter\Translation\Translator"/>
            <argument type="service" id="Shopware\Core\System\Locale\LanguageLocaleCodeProvider"/>
            <argument type="service" id="Doctrine\DBAL\Connection"/>
        </service>

        <service id="Shopware\Core\Content\Mail\Service\MailAttachmentsBuilder" public="true">
            <argument type="service" id="Shopware\Core\Content\Media\MediaService"/>
            <argument type="service" id="media.repository"/>
            <argument type="service" id="Shopware\Core\Checkout\Document\Service\DocumentGenerator"/>
            <argument type="service" id="Doctrine\DBAL\Connection"/>
        </service>

        <service id="core_mailer" alias="mailer" />

        <service id="Shopware\Core\Content\Mail\Transport\MailerTransportLoader">
            <argument type="service" id="mailer.transport_factory"/>
            <argument type="service" id="Shopware\Core\System\SystemConfig\SystemConfigService"/>
            <argument type="service" id="Shopware\Core\Content\Mail\Service\MailAttachmentsBuilder"/>
            <argument type="service" id="shopware.filesystem.public"/>
            <argument type="service" id="document.repository"/>
        </service>

        <service id="Shopware\Core\Content\Mail\Transport\SmtpOauthTransportFactoryDecorator"
                 decorates="mailer.transport_factory.smtp">
            <argument type="service" id="Shopware\Core\Content\Mail\Transport\SmtpOauthTransportFactoryDecorator.inner"/>
            <argument type="service" id="Shopware\Core\Content\Mail\Transport\SmtpOauthAuthenticator"/>
        </service>

        <service id="Shopware\Core\Content\Mail\Transport\SmtpOauthAuthenticator">
            <argument type="service" id="Shopware\Core\Content\Mail\Transport\SmtpOauthTokenProvider"/>
        </service>

        <service id="Shopware\Core\Content\Mail\Transport\SmtpOauthTokenProvider">
            <argument type="service" id="http_client"/>
            <argument type="service" id="cache.object"/>
            <argument type="service" id="Shopware\Core\System\SystemConfig\SystemConfigService"/>
        </service>

        <service id="Shopware\Core\Content\Mail\Subscriber\FailedMessageSubscriber">
            <argument type="service" id="Doctrine\DBAL\Connection"/>

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