An Adobe Commerce developer is developing a custom module. As part of their implementation they have decided that all instances of their Custom\Module\Model\Example class should receive a new instance of Magento\Filesystem\Adapter\Local.
How would the developer achieve this using di. xml?
A)

B)

C)

Suggested Answer: B
Get Premium AD0-E716 Questions
as Interactive Web-Based Practice Test or PDF
Real Exam Format
Detailed Explanations
Instant Access
Get Your Practice Test
The developer can achieve this by adding the following configuration to their di.xml file:
XML
<config>
<component name='CustomModuleModelExample' factory='CustomModuleModelExampleFactory'>
</component>
</config>
This configuration will ensure that all instances of the CustomModuleModelExample class will receive a new instance of the MagentoFilesystemAdapterLocal class.
19 comments · newest first
SU
Sunny
1 month ago
Exactly! B handles it better in the long run.
LA
Laine
2 months ago
Complexity can lead to issues later.
JO
Jose
2 months ago
True, but A is less complex.
SU
Sunny
2 months ago
Agreed! A might miss some details.
LA
Laine
2 months ago
A has its merits, but B feels more complete.
JO
Jose
2 months ago
I prefer Option A. It looks more straightforward to me.
SU
Sunny
3 months ago
It seems to properly configure the dependency injection.
LA
Laine
3 months ago
Why B?
SU
Sunny
3 months ago
Definitely! I lean towards Option B.
LA
Laine
3 months ago
I think this question is tricky.
YO
Yoko
3 months ago
I’m surprised they didn’t mention constructor injection!
CI
Ciara
3 months ago
Wait, why would they need a new instance for every class?
ME
Melodie
4 months ago
Not sure about that, Option C seems off.
EU
Eulah
5 months ago
I think Option B is the way to go!
CU
Curt
5 months ago
Option A looks correct to me.
EM
Emmanuel
6 months ago
I feel like I might be mixing up the syntax for preferences and virtual types. This is tricky!
DE
Denae
6 months ago
I'm leaning towards Option B, but I can't recall if we need to use `` for the constructor parameters.
IZ
Izetta
6 months ago
I practiced a similar question where we had to inject a different class, and I think it involved using the `` tag.
SK
Skye
7 months ago
I think I remember that we need to define the preference in di.xml, but I'm not entirely sure how to specify the arguments correctly.