I had this use case in my theme, where I wanted to expose a bunch of settings to my page.html.twig. Typical things would be social media links. Here is how I looped over config file values, preventing me to write a lot of lines:
/**
* Implements hook_preprocess_page().
*/
function mytheme_preprocess_page(&$variables) {
$config = \Drupal::config('platform.customconfig');
foreach($config->getRawData() as $key => $value) {
$variables[$key] = $value;
}
// This is the same as:
// $variables['facebook_url'] = $config->get('facebook_url');
// $variables['linkedin_url'] = $config->get('linkedin_url');
// $variables['twitter_url'] = $config->get('twitter_url');
}
Now in my page.html.twig I can use all of my values:
{{ linkedin_url }}