Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / chi-teck / drupal-code-generator / templates / d8 / hook / config_translation_info.twig
1 /**
2  * Implements hook_config_translation_info().
3  */
4 function {{ machine_name }}_config_translation_info(&$info) {
5   $entity_manager = \Drupal::entityManager();
6   $route_provider = \Drupal::service('router.route_provider');
7
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) {
13       $base_route = NULL;
14       try {
15         $base_route = $route_provider->getRouteByName('entity.field_config.' . $entity_type_id . '_field_edit_form');
16       }
17       catch (RouteNotFoundException $e) {
18         // Ignore non-existent routes.
19       }
20
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,
29           'weight' => 10,
30         ];
31       }
32     }
33   }
34 }