September 2018
Beginner to intermediate
218 pages
4h 27m
English
Proxy classes are used when object creation is expensive and a class' constructor is unusually resource-intensive. To avoid unnecessary performance impact, Magento uses Proxy classes to turn given types into becoming lazy-loaded versions of them.
A quick lookup for the \Proxy</argument> string across all Magento di.xml files reveals over a hundred occurrences of this string. It goes to say that Magento extensively uses proxies across its code.
The type definition under <MAGENTO_DIR>/module-customer/etc/di.xml is a nice example of using proxies:
<type name="Magento\Customer\Model\Session"> <arguments> <argument name="configShare" xsi:type="object">Magento\Customer\Model\Config\Share\Proxy</argument> <argument name="customerUrl" xsi:type="object">Magento\Customer\Model\Url\Proxy</argument> ...
Read now
Unlock full access