AD0-E717 practice question 1 of 15
A developer is creating a class \Vendor\Module\Model\MyModeL How should that class be defined as transient in di.xml?
Full set: 77 questionsIn Magento's dependency injection (DI) framework, an object's lifecycle is controlled by its configuration in di.xml. By default, objects are "shared" (singletons), meaning the object manager creates only one instance per request. To make an object "transient," which means a new instance is created every time it is requested, you must explicitly configure it as non-shared. The correct syntax for this is setting the shared attribute of the node to false. This instructs the DI container not to share the instance, effectively making it transient.
A. The transient attribute is not a valid attribute for the node in the di.xml schema.
B. The singleton attribute is not a valid attribute for the node in the di.xml schema. While the concept is correct, the syntax is not.
1. Adobe Commerce Developer Documentation, Configure object types:
Section: The element
Quote: "The shared attribute is a boolean that determines if a single instance of the object is created. If shared is false, the object manager creates a new instance of the object every time it is requested. This is also known as a transient object. The default value is true."
Source: Adobe Commerce Developer Documentation, "Configure object types", https://developer.adobe.com/commerce/php/development/build/dependency-injection-file/ (Accessed under the "The element" section).
2. Adobe Commerce Developer Documentation, Technical Bulletin: Validate your XML:
Section: di.xml
Reference: This document points to the official URN for the di.xml schema (urn:magento:framework:ObjectManager/etc/config.xsd). Analyzing this schema file confirms that for the type element, shared is a valid attribute, while transient and singleton are not.
Source: Adobe Commerce Developer Documentation, "Technical Bulletin: Validate your XML", https://developer.adobe.com/commerce/php/development/build/validate-xml/
Keep practicing
Take the free AD0-E717 practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other AD0-E717 practice questions
- Question 2What is one purpose of a customer data JS library?
- Question 3What folder would a developer place a custom patch on an Adobe Commerce Cloud project to …
- Question 4What action can be performed from the Cloud Project Portal (Onboarding Ul) of an Adobe Co…
- Question 5What database engine is part of the infrastructure of Adobe Commerce Cloud projects?
- Question 6What is the default store ID for the admin panel?
- Question 7Which Magento project directory is the recommended webroot for the web server?
