Skip to content
This repository has been archived by the owner on Nov 19, 2024. It is now read-only.

2.3.2 release notes: missing information: view models #4840

Closed
thomas-kl1 opened this issue Jun 26, 2019 · 0 comments · Fixed by #4959
Closed

2.3.2 release notes: missing information: view models #4840

thomas-kl1 opened this issue Jun 26, 2019 · 0 comments · Fixed by #4959
Assignees

Comments

@thomas-kl1
Copy link
Member

Incompatible Backward change

Description

An important change has been shipped for the view models in Magento 2.3.2 and is missing in the release notes.
Now the instances of the view models are shared by default. If a view model requires to be a new instance at each time, you have to add the attribute shared="false" on the argument node in the layout xml file.

Eg:

<block class="Magento\Framework\View\Element\Template" name="block.one">
                <arguments>
                    <argument name="dataSource" xsi:type="object" shared="false">Vendor\Module\Model\ResourceModel\Toto\Collection</argument><!-- is a new instance -->
                    <argument name="dataProvider" xsi:type="object">Vendor\Module\ViewModel\DataProvider</argument><!-- is instantiate first here -->
                </arguments>
</block>
<block class="Magento\Framework\View\Element\Template" name="block.two">
                <arguments>
                    <argument name="dataSource" xsi:type="object" shared="false">Vendor\Module\Model\ResourceModel\Toto\Collection</argument><!-- is a new instance -->
                    <argument name="dataProvider" xsi:type="object">Vendor\Module\ViewModel\DataProvider</argument><!-- is the same instance as in block.one -->
                </arguments>
</block>

See PR: magento/magento2#18541

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants