Services

A service is a class that has functions to use in another class or module. This provides an interface for developers to access foreign code in a clean way.

Modules load services from the Drupal utility class.

$field_type_manager = \Drupal::service('plugin.manager.field.field_type');

Classes load services using dependency injection so the class can be tested.

Services are defined in *.services.yml files. This is where the "plugin.manager.field.field_type" service name is defined.

Level