Get (custom) config settings programmatically in drupal 8

I will add some code snippets about how to create a custom configuration form in your back-end later. This snippet shows how to get the data added to these forms in your custom module. The following snippet shows how to get a boolean value, based on the saved configuration of a custom module :

$is_enabled = \Drupal::config('mymodule.settings')->get('enabled');
if($is_enabled === 1) {
  // do stuff
}

 

 

Saved you some valuable time?

Buy me a drink 🍺 to keep me motivated to create free content like this!