A developer is creating a class VendorModuleModelMyModeL How should that class be defined as transient in di.xml?

A developer is creating a class VendorModuleModelMyModeL How should that class be defined as transient in di.xml?
A . <type name="VendorModuleModelMyModer transient="true7>
B. <type name="VendorModuleModelMyModer singleton=’false7>
C. <type name=’VendorModuleModelMyModer shared="false7>

Answer: C

Explanation:

In Magento 2’s di.xml, if you want to define a class as transient (meaning a new instance is created every time it’s requested), you would use the shared attribute and set it to false.

This definition ensures that a new instance of MyModel is created every time it’s requested from the object manager.

Latest AD0-E717 Practice Questions with 77 Q&As

Updated Study Material | Instant Download | Detailed Answers and Explanations

Subscribe
Notify of
guest
0 Comments