March 2019
Intermediate to advanced
580 pages
15h 3m
English
Lazy builders are nothing more than callbacks on a render array that Drupal can use to build the render array at a later stage. The callbacks can be static (a reference to a class and method) or dynamic (a reference to a service and method). Using the latter approach is more flexible as we can inject dependencies from the container as we do regularly with services. Moreover, the callback can take parameters, which means it can build the render array already having at least part of the required data.
The best way to understand this is to see an example. Since we decided that our salutation component should have a cache lifetime of 0 seconds, it's a good opportunity to build it using a lazy builder.
The first thing we need to ...