1.12.x config.api.php hook_config_info()
1.10.x config.api.php hook_config_info()
1.11.x config.api.php hook_config_info()
1.7.x config.api.php hook_config_info()

Provides a list of configuration prefixes for describing configuration files.

This hook may be used to expose individual configuration files in the UI for exporting. Each entry in the returned array should contain at least the following values:

  • label: A translated string for the name of the configuration file.
  • name_key: A string or array indicating the entry or entries within the configuration file that will be used as the machine name. If specifying an array, it should be ordered the same as the name of the configuration file. For example if the configuration file is named "my_module.feature.key_a.key_b.json", the expected name keys would be array('key_a', 'key_b'). In most case when only a single key is needed, the name_key can be specified as a simple string.
  • label_key: A string indicating the entry within the configuration file that will be used as a label.
  • label_callback: Alternatively, if the "label" or "label_key" options are not suitable for generating a label, a function may be specified as a label callback.
  • group: A translated string to be used as the configuration group.

Related topics

File

modules/config/config.api.php, line 31
Documentation for hooks provided by Config module.

Code

function hook_config_info() {
  // If there are a large number of configuration files prefixed with this
  // string, provide a "name_key" that will be read from the configuration file
  // and used when listing the configuration file.
  $prefixes['image.style'] = array(
    'name_key' => 'name',
    'label_key' => 'name',
    'group' => t('Image styles'),
  );
  // If this configuration file points to one particular file, a "name" key
  // will display that exact string for that file.
  $prefixes['system.core'] = array(
    'label' => t('System performance'),
    'group' => t('Configuration'),
  );
  return $prefixes;
}