<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="Magento\Sales\Api\OrderCustomerManagementInterface">
        <plugin name="Ddg_CustomerManagementPlugin" type="Dotdigitalgroup\Email\Plugin\CustomerManagementPlugin" sortOrder="1"/>
    </type>
    <type name="Magento\Newsletter\Model\Subscriber">
        <plugin name="ddg_newsletter_disabler" type="Dotdigitalgroup\Email\Plugin\SubscriberPlugin" sortOrder="1" disabled="false"/>
    </type>
    <type name="Magento\Customer\Model\Customer">
        <plugin name="ddg_customer_sendNewAccountEmail_disabler" type="Dotdigitalgroup\Email\Plugin\CustomerPlugin" sortOrder="1" disabled="false"/>
    </type>
    <type name="Magento\Customer\Model\EmailNotificationInterface">
        <plugin name="ddg_customer_email_disabler" type="Dotdigitalgroup\Email\Plugin\CustomerEmailNotificationPlugin" sortOrder="1" disabled="false"/>
    </type>
    <type name="Magento\Framework\Mail\TransportInterface">
        <plugin name="ddg_mail_transport" type="Dotdigitalgroup\Email\Plugin\TransportPlugin" sortOrder="1" disabled="false" />
    </type>
    <type name="Magento\Reports\Model\ResourceModel\Product\Collection">
        <plugin name="ddg_reports_product_collection" type="Dotdigitalgroup\Email\Plugin\ReportsProductCollectionPlugin"/>
    </type>
    <type name="Magento\Framework\Mail\Template\TransportBuilder">
        <plugin name="Ddg_TransportBuilderPlugin" type="Dotdigitalgroup\Email\Plugin\TransportBuilderPlugin" sortOrder="1" disabled="false" />
    </type>
    <type name="Magento\Email\Model\Template">
        <plugin name="dotmailer_template_plugin" type="Dotdigitalgroup\Email\Plugin\TemplatePlugin" sortOrder="100" disabled="false"/>
    </type>
    <type name="Magento\Framework\Mail\MessageInterface">
        <plugin name="dotmailer_message_plugin" type="Dotdigitalgroup\Email\Plugin\MessagePlugin" sortOrder="1" disabled="false" />
    </type>
    <type name="Magento\Newsletter\Controller\Manage\Index">
        <plugin name="dotmailer_newsletter_plugin" type="Dotdigitalgroup\Email\Plugin\NewsletterManageIndexPlugin" sortOrder="1"/>
    </type>
    <type name="Magento\UrlRewrite\Controller\Adminhtml\Url\Rewrite\Save">
        <plugin name="dotmailer_url_rewrite_save_plugin" type="Dotdigitalgroup\Email\Plugin\UrlRewriteSavePlugin" sortOrder="1"/>
    </type>
    <type name="Magento\SalesRule\Api\CouponRepositoryInterface">
        <plugin name="coupon_plugin" type="Dotdigitalgroup\Email\Plugin\CouponPlugin"/>
    </type>
    <type name="Magento\SalesRule\Model\ResourceModel\Coupon\Collection">
        <plugin name="ddg_generated_for_email_plugin" type="Dotdigitalgroup\Email\Plugin\CouponCollectionPlugin"/>
    </type>
    <type name="Magento\SalesRule\Model\Utility">
        <plugin name="ddg_coupon_expired_plugin" type="Dotdigitalgroup\Email\Plugin\CouponExpiredPlugin"/>
    </type>
    <type name="Magento\Catalog\Ui\DataProvider\Product\ProductRenderCollectorComposite">
        <arguments>
            <argument name="productProviders" xsi:type="array">
                <item name="ddg_wbt" xsi:type="object">Dotdigitalgroup\Email\Ui\DataProvider\WebBehaviourTracking</item>
            </argument>
        </arguments>
    </type>
    <virtualType name="ContactCustomPrice" type="Magento\Framework\Pricing\Price\Pool">
        <arguments>
            <argument name="prices" xsi:type="array">
                <item name="final_price" xsi:type="string">Magento\ConfigurableProduct\Pricing\Price\FinalPrice</item>
            </argument>
            <argument name="target" xsi:type="object">Magento\Catalog\Pricing\Price\Pool</argument>
        </arguments>
    </virtualType>
    <virtualType name="dotdigitalgroupZendDate" type="Zend_Date">
        <arguments>
            <argument name="date" xsi:type="null"/>
            <argument name="part" xsi:type="null"/>
            <argument name="locale" xsi:type="null"/>
        </arguments>
    </virtualType>
    <type name="Dotdigitalgroup\Email\Helper\Recommended">
        <arguments>
            <argument name="date" xsi:type="object">dotdigitalgroupZendDate</argument>
        </arguments>
    </type>
    <virtualType name="dotdigitalgroupZendMailTransportSendmail" type="Zend_Mail_Transport_Sendmail">
        <arguments>
            <argument name="parameters" xsi:type="null"/>
        </arguments>
    </virtualType>
    <type name="Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory">
        <arguments>
            <argument name="collections" xsi:type="array">
                <item name="cron_report_grid_data_source" xsi:type="string">Magento\Cron\Ui\Model\ResourceModel\Schedule\Collection</item>
                <item name="rules_report_grid_data_source" xsi:type="string">Dotdigitalgroup\Email\Ui\Model\ResourceModel\Rules\Collection</item>
                <item name="importer_report_grid_data_source" xsi:type="string">Dotdigitalgroup\Email\Ui\Model\ResourceModel\Importer\Collection</item>
                <item name="automation_report_grid_data_source" xsi:type="string">Dotdigitalgroup\Email\Ui\Model\ResourceModel\Automation\Collection</item>
                <item name="campaign_report_grid_data_source" xsi:type="string">Dotdigitalgroup\Email\Ui\Model\ResourceModel\Campaign\Collection</item>
                <item name="contact_report_grid_data_source" xsi:type="string">Dotdigitalgroup\Email\Ui\Model\ResourceModel\Contact\Collection</item>
                <item name="catalog_report_grid_data_source" xsi:type="string">Dotdigitalgroup\Email\Ui\Model\ResourceModel\Catalog\Collection</item>
                <item name="order_report_grid_data_source" xsi:type="string">Dotdigitalgroup\Email\Ui\Model\ResourceModel\Order\Collection</item>
                <item name="review_report_grid_data_source" xsi:type="string">Dotdigitalgroup\Email\Ui\Model\ResourceModel\Review\Collection</item>
                <item name="wishlist_report_grid_data_source" xsi:type="string">Dotdigitalgroup\Email\Ui\Model\ResourceModel\Wishlist\Collection</item>
                <item name="abandoned_report_grid_data_source" xsi:type="string">Dotdigitalgroup\Email\Ui\Model\ResourceModel\Abandoned\Collection</item>
            </argument>
        </arguments>
    </type>
    <type name="Magento\Framework\Console\CommandList">
        <arguments>
            <argument name="commands" xsi:type="array">
                <item name="import_data" xsi:type="object">Dotdigitalgroup\Email\Console\Command\ImportDataCommand</item>
                <item name="importer_syncs" xsi:type="object">Dotdigitalgroup\Email\Console\Command\ImporterSyncsCommand</item>
                <item name="enable_connector" xsi:type="object">Dotdigitalgroup\Email\Console\Command\EnableConnectorCommand</item>
                <item name="automap_datafields" xsi:type="object">Dotdigitalgroup\Email\Console\Command\AutoMapDataFieldsCommand</item>
            </argument>
        </arguments>
    </type>
    <preference for="Magento\Config\Model\Config\Structure\SearchInterface" type="Magento\Config\Model\Config\Structure" />
    <preference for="Magento\Sales\Api\Data\OrderSearchResultInterface" type="Magento\Sales\Model\ResourceModel\Order\Collection" />
    <preference for="Magento\SalesRule\Model\Coupon\CodegeneratorInterface" type="Dotdigitalgroup\Email\Model\SalesRule\DotdigitalCouponCodeGenerator" />
    <preference for="Magento\Framework\Mail\Template\SenderResolverInterface" type="Dotdigitalgroup\Email\Model\Email\DotdigitalSenderResolver" />
    <preference for="Dotdigitalgroup\Email\Api\CouponAttributeRepositoryInterface" type="Dotdigitalgroup\Email\Model\Coupon\CouponAttributeRepository"/>
    <preference for="Dotdigitalgroup\Email\Api\Data\CouponAttributeInterface" type="Dotdigitalgroup\Email\Model\Coupon\CouponAttribute"/>
    <preference for="Dotdigitalgroup\Email\Api\TierPriceFinderInterface" type="Dotdigitalgroup\Email\Model\Product\TierPriceFinder" />
    <preference for="Magento\Framework\Filesystem\DriverInterface" type="Magento\Framework\Filesystem\Driver\File" />
    <type name="Dotdigitalgroup\Email\Logger\Handler\ConnectorLogHandler">
        <arguments>
            <argument name="filesystem" xsi:type="object">Magento\Framework\Filesystem\Driver\File</argument>
        </arguments>
    </type>
    <type name="Dotdigitalgroup\Email\Logger\Logger">
        <arguments>
            <argument name="name" xsi:type="string">dotdigital</argument>
            <argument name="handlers"  xsi:type="array">
                <item name="connector_log_handler" xsi:type="object">Dotdigitalgroup\Email\Logger\Handler\ConnectorLogHandler</item>
            </argument>
        </arguments>
    </type>
</config>
