5 * Hooks provided by the Configuration Translation module.
14 * Introduce dynamic translation tabs for translation of configuration.
16 * This hook augments MODULE.config_translation.yml as well as
17 * THEME.config_translation.yml files to collect dynamic translation mapper
18 * information. If your information is static, just provide such a YAML file
19 * with your module containing the mapping.
21 * Note that while themes can provide THEME.config_translation.yml files this
22 * hook is not invoked for themes.
25 * An associative array of configuration mapper information. Use an entity
26 * name for the key (for entity mapping) or a unique string for configuration
27 * name list mapping. The values of the associative array are arrays
28 * themselves in the same structure as the *.config_translation.yml files.
30 * @see hook_config_translation_info_alter()
31 * @see \Drupal\config_translation\ConfigMapperManagerInterface
32 * @see \Drupal\config_translation\Routing\RouteSubscriber::routes()
34 function hook_config_translation_info(&$info) {
35 $entity_manager = \Drupal::entityManager();
36 $route_provider = \Drupal::service('router.route_provider');
38 // If field UI is not enabled, the base routes of the type
39 // "entity.field_config.{$entity_type}_field_edit_form" are not defined.
40 if (\Drupal::moduleHandler()->moduleExists('field_ui')) {
41 // Add fields entity mappers to all fieldable entity types defined.
42 foreach ($entity_manager->getDefinitions() as $entity_type_id => $entity_type) {
45 $base_route = $route_provider->getRouteByName('entity.field_config.' . $entity_type_id . '_field_edit_form');
47 catch (RouteNotFoundException $e) {
48 // Ignore non-existent routes.
51 // Make sure entity type has field UI enabled and has a base route.
52 if ($entity_type->get('field_ui_base_route') && !empty($base_route)) {
53 $info[$entity_type_id . '_fields'] = [
54 'base_route_name' => 'entity.field_config.' . $entity_type_id . '_field_edit_form',
55 'entity_type' => 'field_config',
56 'title' => t('Title'),
57 'class' => '\Drupal\config_translation\ConfigFieldMapper',
58 'base_entity_type' => $entity_type_id,
67 * Alter existing translation tabs for translation of configuration.
69 * This hook is useful to extend existing configuration mappers with new
70 * configuration names, for example when altering existing forms with new
71 * settings stored elsewhere. This allows the translation experience to also
72 * reflect the compound form element in one screen.
75 * An associative array of discovered configuration mappers. Use an entity
76 * name for the key (for entity mapping) or a unique string for configuration
77 * name list mapping. The values of the associative array are arrays
78 * themselves in the same structure as the *.config_translation.yml files.
80 * @see hook_translation_info()
81 * @see \Drupal\config_translation\ConfigMapperManagerInterface
83 function hook_config_translation_info_alter(&$info) {
84 // Add additional site settings to the site information screen, so it shows
85 // up on the translation screen. (Form alter in the elements whose values are
86 // stored in this config file using regular form altering on the original
87 // configuration form.)
88 $info['system.site_information_settings']['names'][] = 'example.site.setting';
92 * @} End of "addtogroup hooks".