<?xml version="1.0"?>
<!--
/**
 * BSS Commerce Co.
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the EULA
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://bsscommerce.com/Bss-Commerce-License.txt
 *
 * @category   BSS
 * @package    Bss_CustomerAttributes
 * @author     Extension Team
 * @copyright  Copyright (c) 2018-2019 BSS Commerce Co. ( http://bsscommerce.com )
 * @license    http://bsscommerce.com/Bss-Commerce-License.txt
 */
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
	<type name="Magento\Customer\Model\Attribute">
        <plugin name="add_input_type" type="Bss\CustomerAttributes\Model\Plugin\ManagerPlugin" sortOrder="10"/>
    </type>
    <preference for="Magento\Eav\Model\ResourceModel\Entity\Attribute" type="Bss\CustomerAttributes\Model\ResourceModel\Entity\Attribute" />
    <preference for="Magento\Customer\Ui\Component\Listing\Columns" type="Bss\CustomerAttributes\Ui\Component\Listing\Columns" />
    <preference for="Magento\Customer\Ui\Component\ColumnFactory" type="Bss\CustomerAttributes\Ui\Component\ColumnFactory" />
    <type name="Magento\Sales\Block\Adminhtml\Order\View\Info">
        <plugin name="display_file_attribute" type="Bss\CustomerAttributes\Plugin\Adminhtml\Order\View\Info" sortOrder="10"/>
    </type>
    <type name="Magento\Eav\Api\Data\AttributeInterface">
        <plugin name="add_input_type_attribute" type="Bss\CustomerAttributes\Plugin\Adminhtml\Attribute" sortOrder="10"/>
    </type>
    <type name="Magento\Customer\Ui\Component\DataProvider">
        <plugin name="bss_customer_attributes_plugin_edit_name_attribute_file_grid" type="Bss\CustomerAttributes\Plugin\Ui\Component\DataProvider" sortOrder="10"/>
    </type>
    <type name="Magento\Eav\Model\Attribute\Data\Text">
        <plugin name="bss_customer_attributes_plugin_eav_validate_form_text" type="Bss\CustomerAttributes\Plugin\Model\Metadata\Form\ValidateValue" sortOrder="10"/>
    </type>
    <type name="Magento\Customer\Model\Metadata\Form">
        <plugin name="bss_customer_address_attributes_plugin_save_form_edit_admin" type="Bss\CustomerAttributes\Plugin\Model\Metadata\Form" sortOrder="10"/>
    </type>

    <!-- Start BSS B2BRegistration module integration -->
    <!-- Supplies the data for the customer UI component => Refactored version of Magento\Customer\Model\Customer\DataProvider with eliminated usage of addresses collection -->
    <type name="Magento\Customer\Model\ResourceModel\CustomerRepository">
        <plugin name="bss_save_registry" type="Bss\CustomerAttributes\Plugin\Integration\Model\ResourceModel\CustomerRepository"/>
    </type>
    <type name="Magento\Eav\Model\Entity\Attribute\Backend\ArrayBackend">
        <plugin name="bss_b2b_customer_attributes_plugin_eav_validate_backend_model_multi" type="Bss\CustomerAttributes\Plugin\Integration\Model\Attribute\Backend\ValidateValue"/>
    </type>
    <!-- End BSS B2BRegistration module integration -->

    <preference for="Magento\Customer\Model\Customer\DataProviderWithDefaultAddresses" type="Bss\CustomerAttributes\Model\Customer\DataProviderWithDefaultAddresses"/>

    <type name="Magento\Customer\Controller\Adminhtml\Address\Save">
        <plugin name="bss_c_a_default_address_customer_page" type="Bss\CustomerAttributes\Plugin\Customer\Controller\Adminhtml\Address\Save"/>
    </type>

    <type name="Magento\Sales\Model\AdminOrder\Create">
        <plugin name="bss_c_a_handle_upload_file" type="Bss\CustomerAttributes\Plugin\Sales\Model\AdminOrder\Create"/>
    </type>

    <type name="Magento\Sales\Controller\Adminhtml\Order\AddressSave">
        <plugin name="bss_c_a_handle_upload_file_address_save" type="Bss\CustomerAttributes\Plugin\Sales\Controller\Adminhtml\Order\AddressSave"/>
    </type>
    <type name="Magento\CustomerCustomAttributes\Model\Customer\Attribute\Validator\FileExtension">
        <plugin name="set_default_value_file_extensions" type="Bss\CustomerAttributes\Plugin\Model\Customer\Attribute\Validator\FileExtension"/>
    </type>
</config>
