<?xml version="1.0"?>
<!--
/**
 * Copyright © MageWorx. All rights reserved.
 * See LICENSE.txt for license details.
 */
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">

    <preference for="MageWorx\Downloads\Api\AttachmentRepositoryInterface" type="MageWorx\Downloads\Model\AttachmentRepository"/>
    <preference for="MageWorx\Downloads\Api\Data\AttachmentSearchResultsInterface" type="Magento\Framework\Api\SearchResults"/>
    <preference for="MageWorx\Downloads\Api\Data\AttachmentInterface" type="MageWorx\Downloads\Model\Attachment"/>
    <preference for="MageWorx\Downloads\Api\Data\AttachmentLocaleInterface" type="MageWorx\Downloads\Model\Attachment\AttachmentLocale"/>
    <preference for="MageWorx\Downloads\Api\Data\AttachmentLinkInterface" type="MageWorx\Downloads\Model\AttachmentLink"/>
    <preference for="MageWorx\Downloads\Api\Data\File\ContentUploaderInterface" type="MageWorx\Downloads\Model\File\ContentUploader"/>
    <preference for="MageWorx\Downloads\Api\Data\File\ContentInterface" type="MageWorx\Downloads\Model\File\Content"/>
    <preference for="MageWorx\Downloads\Api\AttachmentManagerInterface" type="MageWorx\Downloads\Model\AttachmentManager"/>
    <preference for="MageWorx\Downloads\Api\GuestAttachmentManagerInterface" type="MageWorx\Downloads\Model\GuestAttachmentManager"/>
    <preference for="MageWorx\Downloads\Api\Data\SectionInterface" type="MageWorx\Downloads\Model\Section"/>
    <preference for="MageWorx\Downloads\Api\Data\SectionLocaleInterface" type="MageWorx\Downloads\Model\Section\SectionLocale"/>
    <preference for="MageWorx\Downloads\Api\SectionRepositoryInterface" type="MageWorx\Downloads\Model\SectionRepository"/>
    <preference for="MageWorx\Downloads\Api\Data\SectionSearchResultsInterface" type="Magento\Framework\Api\SearchResults"/>

    <virtualType name="MageWorxDownloadsAttachmentGridDataProvider" type="Magento\Framework\View\Element\UiComponent\DataProvider\DataProvider">
        <arguments>
            <argument name="collection" xsi:type="object" shared="false">MageWorx\Downloads\Model\ResourceModel\Attachment\Collection</argument>
            <argument name="filterPool" xsi:type="object" shared="false">MageWorxDownloadsGridFilterPool</argument>
        </arguments>
    </virtualType>
    <virtualType name="MageWorxDownloadsGridFilterPool" type="Magento\Framework\View\Element\UiComponent\DataProvider\FilterPool">
        <arguments>
            <argument name="appliers" xsi:type="array">
                <item name="regular" xsi:type="object">Magento\Framework\View\Element\UiComponent\DataProvider\RegularFilter</item>
                <item name="fulltext" xsi:type="object">Magento\Framework\View\Element\UiComponent\DataProvider\FulltextFilter</item>
            </argument>
        </arguments>
    </virtualType>
    <type name="MageWorx\Downloads\Model\ResourceModel\Attachment\Grid\Collection">
        <arguments>
            <argument name="mainTable" xsi:type="string">mageworx_downloads_attachment</argument>
            <argument name="eventPrefix" xsi:type="string">mageworx_downloads_attachment_grid_collection</argument>
            <argument name="eventObject" xsi:type="string">attachment_grid_collection</argument>
            <argument name="resourceModel" xsi:type="string">MageWorx\Downloads\Model\ResourceModel\Attachment</argument>
        </arguments>
    </type>
    <type name="Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory">
        <arguments>
            <argument name="collections" xsi:type="array">
                <item name="mageworx_downloads_attachment_listing_data_source" xsi:type="string">MageWorx\Downloads\Model\ResourceModel\Attachment\Grid\Collection</item>
                <item name="mageworx_downloads_section_listing_data_source" xsi:type="string">MageWorx\Downloads\Model\ResourceModel\Section\Grid\Collection</item>
            </argument>
        </arguments>
    </type>
    <virtualType name="MageWorxDownloadsSectionGridDataProvider" type="Magento\Framework\View\Element\UiComponent\DataProvider\DataProvider">
        <arguments>
            <argument name="collection" xsi:type="object" shared="false">MageWorx\Downloads\Model\ResourceModel\Section\Collection</argument>
            <argument name="filterPool" xsi:type="object" shared="false">MageWorxDownloadsGridFilterPool</argument>
        </arguments>
    </virtualType>
    <type name="MageWorx\Downloads\Model\ResourceModel\Section\Grid\Collection">
        <arguments>
            <argument name="mainTable" xsi:type="string">mageworx_downloads_section</argument>
            <argument name="eventPrefix" xsi:type="string">mageworx_downloads_section_grid_collection</argument>
            <argument name="eventObject" xsi:type="string">section_grid_collection</argument>
            <argument name="resourceModel" xsi:type="string">MageWorx\Downloads\Model\ResourceModel\Section</argument>
        </arguments>
    </type>
</config>
