Dependency Injection in Drupal 8
Click here to watch Dependency Injection in Drupal 8.
Along with its embrace of OOP in general, Drupal 8 has embraced the Dependency Injection pattern in particular. While it's one of the simplest OO design patterns you'll ever come across, Dependency Injection has far-reaching consequences for how we structure and organize our code.
This talk will begin with an explanation of the pattern, discussing its value in a general programming context, and then narrow the focus to look at how we've been making use of DI in Drupal 8 core. The talk will also introduce you to D8's Dependency Injection Container, built on the Dependency Injection component from Symfony, and explain why you need to know about this as a module developer.
If you haven't looked at D8's codebase recently, you might be in for a bit of a shock and feel like you simply don't know where to start in getting up to speed with all the changes. This talk will offer an ideal starting point as it will touch on many of the most fundamental behind-the-scenes changes that anyone writing Drupal code needs to be aware of.
The following questions will be answered in this session:
- What is Dependency Injection?
- What problems does it solve?
- What is a Dependency Injection Container?
- Why is this relevant to me as a module maintainer?
- What are these new "Bundles" that have nothing to do with entities?
- What are compiler passes?
- What are some best practices around Dependency Injection that I should be aware of?