1

I complete my own module. Now when i run the below command for compilation. I got the error. Run this command for compilation :- php bin/magento setup:di:compile

Fatal error:  Uncaught TypeError: Argument 1 passed to Magento\Setup\Module\Di\Compiler\ArgumentsResolver::getConfiguredInstanceArgument() must be of the type array, string given, called in /mage2/setup/src/Magento/Setup/Module/Di/Compiler/ArgumentsResolver.php on line 125 and defined in /mage2/setup/src/Magento/Setup/Module/Di/Compiler/ArgumentsResolver.php:169
Stack trace:
#0 /mage2/setup/src/Magento/Setup/Module/Di/Compiler/ArgumentsResolver.php(125): Magento\Setup\Module\Di\Compiler\ArgumentsResolver->getConfiguredInstanceArgument('test_demo')
#1 /mage2/setup/src/Magento/Setup/Module/Di/Compiler/ArgumentsResolver.php(106): Magento\Setup\Module\Di\Compiler\ArgumentsResolver->getConfiguredArgument('test_demo', Object(Magento\Setup\Module\Di\Compiler\ConstructorArgument))
#2 /mage2/setup/src/Magento/Setup/Module/Di/Compiler/Config/Reader.php(121): Magento\Setup\Module\Di\Compiler\ArgumentsResolver->getResolvedConstructorArguments('Test\\Demo\\Mo...', Array)
# in /mage2/setup/src/Magento/Setup/Module/Di/Compiler/ArgumentsResolver.php on line 169

Now I commented line in this file app/code/Test/Demo/etc/di.xml

<?xml version="1.0"?>

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLosamion="urn:magento:framework:ObjectManager/etc/config.xsd">

    <preference for="Test\Demo\Api\Data\DemoItemInterface"
                type="Test\Demo\Model\Demo" />
    <preference for="Test\Demo\Api\Data\SampleItemInterface"
                type="Test\Demo\Model\Sample" />

    <virtualType name="DemoGirdFilterPool" 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>

    <virtualType name="DemoGridDataProvider" type="Magento\Framework\View\Element\UiComponent\DataProvider\DataProvider">
        <arguments>
            <argument name="collection" xsi:type="object" shared="false">Test\Demo\Model\ResourceModel\Demo\Collection</argument>
            <argument name="filterPool" xsi:type="object" shared="false">DemoGirdFilterPool</argument>
        </arguments>
    </virtualType>

    <!-- <virtualType name="Test\Demo\Model\ResourceModel\Demo\Grid\Collection" type="Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult">
        <arguments>
            <argument name="mainTable" xsi:type="string">Test_Demo</argument>            
            <argument name="resourceModel" xsi:type="string">Test\Demo\Model\ResourceModel\Demo</argument>
        </arguments>
    </virtualType> -->

    <virtualType name="DemoSampleGirdFilterPool" 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>

    <virtualType name="SamGridDataProvider" type="Magento\Framework\View\Element\UiComponent\DataProvider\DataProvider">
        <arguments>
            <argument name="collection" xsi:type="object" shared="false">Test\Demo\Model\ResourceModel\Sample\Collection</argument>
            <argument name="filterPool" xsi:type="object" shared="false">DemoSampleGirdFilterPool</argument>
        </arguments>
    </virtualType>

    <!-- <virtualType name="Test\Demo\Model\ResourceModel\Sample\Grid\Collection" type="Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult">
        <arguments>
            <argument name="mainTable" xsi:type="string">Test_Demo_sam</argument>
            <argument name="resourceModel" xsi:type="string">Test\Demo\Model\ResourceModel\Sample</argument>
        </arguments>
    </virtualType> -->

    <type name="Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory">
        <arguments>
            <argument name="collections" xsi:type="array">
                <item name="Demotab_Demo_listing_data_source" xsi:type="string">Test\Demo\Model\ResourceModel\Demo\Grid\Collection</item>
                <item name="Demo_index_grid_data_source" xsi:type="string">Test\Demo\Model\ResourceModel\Demo\Grid\Collection</item>
                <item name="Sample_index_grid_data_source" xsi:type="string">Test\Demo\Model\ResourceModel\Sample\Grid\Collection</item>
            </argument>
        </arguments>
    </type>

</config>

And 100% compilation done.

1

Now solve the issue. I use below code. I removed two line and solved issue. And also all functionality are working perfect.

<?xml version="1.0"?>

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLosamion="urn:magento:framework:ObjectManager/etc/config.xsd">

    <preference for="Test\Demo\Api\Data\DemoItemInterface"
                type="Test\Demo\Model\Demo" />
    <preference for="Test\Demo\Api\Data\SampleItemInterface"
                type="Test\Demo\Model\Sample" />

    <virtualType name="DemoGirdFilterPool" 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>

    <virtualType name="DemoGridDataProvider" type="Magento\Framework\View\Element\UiComponent\DataProvider\DataProvider">
        <arguments>
            <argument name="collection" xsi:type="object" shared="false">Test\Demo\Model\ResourceModel\Demo\Collection</argument>
            <argument name="filterPool" xsi:type="object" shared="false">DemoGirdFilterPool</argument>
        </arguments>
    </virtualType>

    <virtualType name="Test\Demo\Model\ResourceModel\Demo\Grid\Collection" type="Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult">
        <arguments>            
            <argument name="resourceModel" xsi:type="string">Test\Demo\Model\ResourceModel\Demo</argument>
        </arguments>
    </virtualType>

    <virtualType name="DemoSampleGirdFilterPool" 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>

    <virtualType name="SamGridDataProvider" type="Magento\Framework\View\Element\UiComponent\DataProvider\DataProvider">
        <arguments>
            <argument name="collection" xsi:type="object" shared="false">Test\Demo\Model\ResourceModel\Sample\Collection</argument>
            <argument name="filterPool" xsi:type="object" shared="false">DemoSampleGirdFilterPool</argument>
        </arguments>
    </virtualType>

    <virtualType name="Test\Demo\Model\ResourceModel\Sample\Grid\Collection" type="Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult">
        <arguments>
            <argument name="resourceModel" xsi:type="string">Test\Demo\Model\ResourceModel\Sample</argument>
        </arguments>
    </virtualType>

    <type name="Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory">
        <arguments>
            <argument name="collections" xsi:type="array">
                <item name="Demotab_Demo_listing_data_source" xsi:type="string">Test\Demo\Model\ResourceModel\Demo\Grid\Collection</item>
                <item name="Demo_index_grid_data_source" xsi:type="string">Test\Demo\Model\ResourceModel\Demo\Grid\Collection</item>
                <item name="Sample_index_grid_data_source" xsi:type="string">Test\Demo\Model\ResourceModel\Sample\Grid\Collection</item>
            </argument>
        </arguments>
    </type>

</config>

Now compilation is 100% done.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.