March 2019
Intermediate to advanced
580 pages
15h 3m
English
In the previous section we created a form that allows administrators to set a custom salutation message to be shown on the page. This message was stored in a configuration object that we can now load in our HelloWorldSalutation service. So, let's do just that in a two-step process.
First, we will need to alter our service definition to give our service an argument—the Drupal 8 configuration factory (the service responsible for loading config objects). This is how our service definition should look now:
hello_world.salutation: class: Drupal\hello_world\HelloWorldSalutation arguments: ['@config.factory']
The addition is the argument's key, which is an array of service names proceeded by @. In this case, config.factory
Read now
Unlock full access