2 * Implements hook_config_translation_info().
4 function {{ machine_name }}_config_translation_info(&$info) {
5 $entity_manager = \Drupal::entityManager();
6 $route_provider = \Drupal::service('router.route_provider');
8 // If field UI is not enabled, the base routes of the type
9 // "entity.field_config.{$entity_type}_field_edit_form" are not defined.
10 if (\Drupal::moduleHandler()->moduleExists('field_ui')) {
11 // Add fields entity mappers to all fieldable entity types defined.
12 foreach ($entity_manager->getDefinitions() as $entity_type_id => $entity_type) {
15 $base_route = $route_provider->getRouteByName('entity.field_config.' . $entity_type_id . '_field_edit_form');
17 catch (RouteNotFoundException $e) {
18 // Ignore non-existent routes.
21 // Make sure entity type has field UI enabled and has a base route.
22 if ($entity_type->get('field_ui_base_route') && !empty($base_route)) {
23 $info[$entity_type_id . '_fields'] = [
24 'base_route_name' => 'entity.field_config.' . $entity_type_id . '_field_edit_form',
25 'entity_type' => 'field_config',
26 'title' => t('Title'),
27 'class' => '\Drupal\config_translation\ConfigFieldMapper',
28 'base_entity_type' => $entity_type_id,