W3cubDocs

/Drupal 8

function hook_config_schema_info_alter

hook_config_schema_info_alter(&$definitions)

Alter config typed data definitions.

For example you can alter the typed data types representing each configuration schema type to change default labels or form element renderers used for configuration translation.

If implementations of this hook add or remove configuration schema a ConfigSchemaAlterException will be thrown. Keep in mind that there are tools that may use the configuration schema for static analysis of configuration files, like the string extractor for the localization system. Such systems won't work with dynamically defined configuration schemas.

For adding new data types use configuration schema YAML files instead.

Parameters

$definitions: Associative array of configuration type definitions keyed by schema type names. The elements are themselves array with information about the type.

See also

\Drupal\Core\Config\TypedConfigManager

\Drupal\Core\Config\Schema\ConfigSchemaAlterException

Related topics

Hooks
Define functions that alter the behavior of Drupal core.

File

core/core.api.php, line 2217
Documentation landing page and topics, plus core library hooks.

Code

function hook_config_schema_info_alter(&$definitions) {
  // Enhance the text and date type definitions with classes to generate proper
  // form elements in ConfigTranslationFormBase. Other translatable types will
  // appear as a one line textfield.
  $definitions['text']['form_element_class'] = '\Drupal\config_translation\FormElement\Textarea';
  $definitions['date_format']['form_element_class'] = '\Drupal\config_translation\FormElement\DateFormat';
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!core.api.php/function/hook_config_schema_info_alter/8.1.x