Skip to main content
1 of 2
4uk4
  • 101.7k
  • 7
  • 173
  • 217

But I am not even sure if this is correct. And the details eludes me. For example: How do I discover what name to include in myservice.services.yml?

Now that Drupal 9 is end of life you no longer need to do that. Replace the argument list with the autowire option:

mymodule.services.yml

services:
  mymodule.my_service:
    class: Drupal\mymodule\MyService
    autowire: true

See the change record: Core services provide aliases for autowiring

4uk4
  • 101.7k
  • 7
  • 173
  • 217