July 2017
Intermediate to advanced
456 pages
11h 32m
English
Now you have a mastering_drupal_8.services.yml file with:
services: mastering_drupal_8.weather_underground: class: Drupal\mastering_drupal_8\WeatherUnderground arguments: ["@http_client"]
The first two lines are pretty simple: we give our service a name, namespace it to our module, and set the class that is used to instantiate the service. That third line defines the arguments that are injected into the service. In this case, since we're going to be making calls to an external API, we need to have an HTTP client. Those two attributes, class, and arguments, are the most common metadata in the services.yml file.
Other, less common, options include:
Read now
Unlock full access