[Drupal] Service dependency injection in a service type class

The code

Additional Information Declare the services your class will use in the .services.yml file of your module. Unlike plugin type class service dependency injection, there is no create method to define the needed services. The __construct signature needs to respect the declared arguments from the .services.yml file. Originally made and tested on […]

[Drupal] Service dependency injection in a plugin type class

The code

Additional Information Unlike service type class service dependency injection, there may be no need to implement an interface to be able to load the needed services, such as extending from ControllerBase. So if you are extending from a class which already has the dependency injection implementation, you can just override the create […]