config_translation_config_translation_info

config_translation_config_translation_info(&$info)

Implements hook_config_translation_info().

File

core/modules/config_translation/config_translation.module, line 102
Configuration Translation module.

Code

function config_translation_config_translation_info(&$info) {
  $entity_manager = \Drupal::entityManager();

  // If field UI is not enabled, the base routes of the type
  // "entity.field_config.{$entity_type}_field_edit_form" are not defined.
  if (\Drupal::moduleHandler()->moduleExists('field_ui')) {
    // Add fields entity mappers to all fieldable entity types defined.
    foreach ($entity_manager->getDefinitions() as $entity_type_id => $entity_type) {
      // Make sure entity type has field UI enabled and has a base route.
      if ($entity_type->get('field_ui_base_route')) {
        $info[$entity_type_id . '_fields'] = array(
          'base_route_name' => "entity.field_config.{$entity_type_id}_field_edit_form",
          'entity_type' => 'field_config',
          'class' => '\Drupal\config_translation\ConfigFieldMapper',
          'base_entity_type' => $entity_type_id,
          'weight' => 10,
        );
      }
    }
  }

  // Discover configuration entities automatically.
  foreach ($entity_manager->getDefinitions() as $entity_type_id => $entity_type) {
    // Determine base path for entities automatically if provided via the
    // configuration entity.
    if (
    !$entity_type->isSubclassOf('Drupal\Core\Config\Entity\ConfigEntityInterface') || 
      !$entity_type->hasLinkTemplate('edit-form')
      ) {
      // Do not record this entity mapper if the entity type does not
      // provide a base route. We'll surely not be able to do anything with
      // it anyway. Configuration entities with a dynamic base path, such as
      // fields, need special treatment. See above.
      continue;
    }

    // Use the entity type as the plugin ID.
    $base_route_name = "entity.$entity_type_id.edit_form";
    $info[$entity_type_id] = array(
      'class' => '\Drupal\config_translation\ConfigEntityMapper',
      'base_route_name' => $base_route_name,
      'title' => $entity_type->getLowercaseLabel(),
      'names' => array(),
      'entity_type' => $entity_type_id,
      'weight' => 10,
    );
  }
}
doc_Drupal
2016-10-29 08:55:25
Comments
Leave a Comment

Please login to continue.