Demystifying Dependency Injection and Services in Drupal 8

Is there a way for someone to modify the process by which Drupal invokes modules without making changes to the core function in Drupal 7 ?

OR Is there a better way to access the global variables without calling them directly in Drupal 7 ? The answer is No.The session aims at understanding the dependency injection and services in Drupal 8 that may be a bit complex but really usable.

The introduction of Object Oriented Programing in Drupal 8 is an evolution in the world of Drupal which has brought the concept of code reuse and encapsulation, allowing users to build better maintainable and structured code.One of the concept that contribute to this is Dependency Injection and Services in Drupal 8.

Dependency injection is an advanced software design pattern. It implements “inversion of control”, which means that reusable code calls task specific code.

Dependency injection :

  • Removes strong dependencies that were in  Drupal 7.(Global variables,Invoking hooks,etc.)

  • Enables us to reuse the functionality and make our services pluggable and replaceable

  • To understand and use best practices such as using service container in a decoupled manner.

  • Make the code easier to read.

  • In Drupal 8, with the adoption of dependency-injection, literally every core subsystem, or services, can be overridden and changed.

The objective of the session are:

  • Problem of reusability in Drupal 7.

  • Overview of Services and Dependency Injection?

  • Drupal 8 core services and how to use them.

  • Services container and it is helpful.

  • How to use Dependency Injection in Contrib modules?

My session will talk about various scenarios and how can we use different services and Dependency Injection in these scenarios.The session will include demos, examples and code walk throughs.

What level of knowledge should attendees have before walking into your session:

This session will be easy to understand for people with intermidiate level knowledge of Drupal.

Take Away for attendees:

  • Best practices of building custom and contrib module using services and dependency injection.
  • Defining your own services.
  • Decoupling of custom modules.

Session Track

Symfony

Experience level

Intermediate

Drupal Version

Drupal 8 (current)

Session Time Slot(s)

Time: 
09/27/2017 - 17:00 to 09/27/2017 - 18:00
Room: 
Lehar 4