<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <preference for="DJOGlobal\ComfortScan\Api\Data\ComfortScanItemsInterface" type="DJOGlobal\ComfortScan\Model\ComfortScanItems"/>
    <preference for="DJOGlobal\ComfortScan\Api\ComfortScanItemsRepositoryInterface" type="DJOGlobal\ComfortScan\Model\ComfortScanItemsRepository"/>

    <!-- plugins -->

    <type name="Magento\Quote\Api\CartRepositoryInterface">
        <plugin name="DJOGlobal_ComfortScan::SaveCustomScanItemsAfterQuoteSave" type="DJOGlobal\ComfortScan\Plugin\SaveCustomScanItemsAfterQuoteSave" sortOrder="99"/>
    </type>
    <type name="Magento\Sales\Api\OrderRepositoryInterface">
        <plugin name="DJOGlobal_ComfortScan::SaveCustomScanItemsAfterOrderPlace" type="DJOGlobal\ComfortScan\Plugin\SaveCustomScanItemsAfterOrderPlace"/>
    </type>

    <type name="Magento\Catalog\Helper\Product\Configuration">
        <plugin name="DJOGlobal_ComfortScan::AddCustomInfoCustomOptionsToItemRenderer" type="DJOGlobal\ComfortScan\Plugin\AddCustomInfoCustomOptionsToItemRenderer"/>
    </type>

    <type name="Magento\Quote\Model\Cart\CartTotalRepository">
        <plugin name="DJOGlobal_ComfortScan::AddComfortScanItemsToTotalsInformationExtensionAttributes" type="DJOGlobal\ComfortScan\Plugin\AddComfortScanItemsToTotalsInformationExtensionAttributes"/>
    </type>

    <type name="Magento\Quote\Model\Quote\Item\ToOrderItem">
        <plugin name="DJOGlobal_ComfortScan::AddCustomInfoToOrderItem" type="DJOGlobal\ComfortScan\Plugin\AddCustomInfoToOrderItem"/>
    </type>

    <type name="\Magento\Sales\Block\Order\Item\Renderer\DefaultRenderer">
        <plugin name="DJOGlobal_ComfortScan::AddCustomInfoToOrderItemRenderer" type="DJOGlobal\ComfortScan\Plugin\AddCustomInfoToOrderItemRenderer"/>
    </type>

    <type name="\Magento\Sales\Block\Adminhtml\Items\Column\DefaultColumn">
        <plugin name="DJOGlobal_ComfortScan::AddCustomInfoToOrderItemRendererAdmin.php" type="DJOGlobal\ComfortScan\Plugin\AddCustomInfoToOrderItemRendererAdmin"/>
    </type>

    <!-- logging -->

    <type name="DJOGlobal\ComfortScan\Logger\Handler">
        <arguments>
            <argument name="filesystem" xsi:type="object">Magento\Framework\Filesystem\Driver\File</argument>
        </arguments>
    </type>
    <type name="DJOGlobal\ComfortScan\Logger\Logger">
        <arguments>
            <argument name="name" xsi:type="string">comfort_scan</argument>
            <argument name="handlers" xsi:type="array">
                <item name="system" xsi:type="object">DJOGlobal\ComfortScan\Logger\Handler</item>
            </argument>
        </arguments>
    </type>

    <!-- admin grid -->

    <virtualType name="DJOGlobalComfortScanItemsGridFilterPool" 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="DJOGlobal\ComfortScan\Ui\Component\Listing\DataProvider">
        <arguments>
            <argument name="collection" xsi:type="object" shared="false">DJOGlobal\ComfortScan\Model\ResourceModel\ComfortScanItems\Collection</argument>
            <argument name="filterPool" xsi:type="object" shared="false">DJOGlobalComfortScanItemsGridFilterPool</argument>
        </arguments>
    </type>

    <type name="DJOGlobal\ComfortScan\Model\ResourceModel\ComfortScanItems\Grid\Collection">
        <arguments>
            <argument name="mainTable" xsi:type="string">djo_comfort_scan_items</argument>
            <argument name="eventPrefix" xsi:type="string">djo_comfortscanitems_grid_collection</argument>
            <argument name="eventObject" xsi:type="string">comfortscanitems_grid_collection</argument>
            <argument name="resourceModel" xsi:type="string">DJOGlobal\ComfortScan\Model\ResourceModel\ComfortScan</argument>
        </arguments>
    </type>

    <type name="Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory">
        <arguments>
            <argument name="collections" xsi:type="array">
                <item name="djo_comfortscanitems_listing_data_source" xsi:type="string">DJOGlobal\ComfortScan\Model\ResourceModel\ComfortScanItems\Grid\Collection</item>
            </argument>
        </arguments>
    </type>
</config>
