Magento Meetup New Delhi- Magento2 code generation
The Slide covers that-
What is code generation?
How it is used?
Why to use code generation in Magento2?
2. Basic
questions that
can explain
the concept ?
What is code
generation ?
What is the need of
code generation
in magento2 ?
How code generation
works ?
4. What is the
need of code
generation in
magento2 ?
to facilitate
DI(Dependency
Injection) in
magento2.
to facilitate
plugin system in
magento2.
fast class loading.
6. Factory
Code
Generation
if a class is
suffixed with
factory and it is
passed to the object
manager or in the
constructor and if
the class is not
existing then
magento will create
the class
automatically.
7.
8.
9. Plugin Code
Generation
if a plugin is
defined in the
di.xml, then its
interceptor class is
created in the
var/generation .
10.
11.
12. Proxy Code
Generation
since magento2 uses
DI design pattern
and you can pass the
class reference in
the constructor and
when the class is
loaded is starts a
domino effect to
overcome this
problem magento2
uses proxy design
pattern .
13.
14.
15.
16.
17.
18. Benefits of
Code
Generation
• don't need to
write test cases
for the generated
classes
• fast class
loading
• best solution for
customization
• generalized
approach