Is there a difference between calling \Drupal::service('config.factory')
and \Drupal::configFactory()
?
Is it better to use the second one?
Can \Drupal
be used to do something else than calling services?
The documentation says:
Accessing services in global functions
The global Drupal class provides static methods to access several of the most common services. For example, Drupal::moduleHandler() will return the module handler service or Drupal::translation() will return the string translation service. If there is no dedicated method for the service you want to use, you can use the Drupal::service() method to retrieve any defined service.
In which cases isn't there any dedicated method? How do I easily list all the retrievable services?