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 2232
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';
}
doc_Drupal
2016-10-29 09:17:52
Comments
Leave a Comment

Please login to continue.