diff --git a/core/modules/config_translation/lib/Drupal/config_translation/ConfigFieldInstanceMapper.php b/core/modules/config_translation/lib/Drupal/config_translation/ConfigFieldInstanceMapper.php index be497e4ab2b..44df444b69d 100644 --- a/core/modules/config_translation/lib/Drupal/config_translation/ConfigFieldInstanceMapper.php +++ b/core/modules/config_translation/lib/Drupal/config_translation/ConfigFieldInstanceMapper.php @@ -18,15 +18,20 @@ namespace Drupal\config_translation; */ class ConfigFieldInstanceMapper extends ConfigEntityMapper { + /** + * Loaded entity instance to help produce the translation interface. + * + * @var \Drupal\field\FieldInstanceInterface + */ + protected $entity; + /** * {@inheritdoc} */ public function getBaseRouteParameters() { $parameters = parent::getBaseRouteParameters(); $base_entity_info = $this->entityManager->getDefinition($this->pluginDefinition['base_entity_type']); - // @todo Field instances have no method to return the bundle the instance is - // attached to. See https://drupal.org/node/2134861 - $parameters[$base_entity_info['bundle_entity_type']] = $this->entity->bundle; + $parameters[$base_entity_info['bundle_entity_type']] = $this->entity->targetBundle(); return $parameters; } diff --git a/core/modules/field/lib/Drupal/field/Entity/FieldInstance.php b/core/modules/field/lib/Drupal/field/Entity/FieldInstance.php index e223d5c7af8..7c2e381a6fb 100644 --- a/core/modules/field/lib/Drupal/field/Entity/FieldInstance.php +++ b/core/modules/field/lib/Drupal/field/Entity/FieldInstance.php @@ -597,6 +597,13 @@ class FieldInstance extends ConfigEntityBase implements FieldInstanceInterface { $this->bundle_rename_allowed = TRUE; } + /** + * {@inheritdoc} + */ + public function targetBundle() { + return $this->bundle; + } + /* * Implements the magic __sleep() method. * diff --git a/core/modules/field/lib/Drupal/field/FieldInstanceInterface.php b/core/modules/field/lib/Drupal/field/FieldInstanceInterface.php index aa06b8308f2..f5df93b332b 100644 --- a/core/modules/field/lib/Drupal/field/FieldInstanceInterface.php +++ b/core/modules/field/lib/Drupal/field/FieldInstanceInterface.php @@ -32,4 +32,12 @@ interface FieldInstanceInterface extends ConfigEntityInterface, FieldDefinitionI */ public function allowBundleRename(); + /** + * Returns the name of the bundle this field instance is attached to. + * + * @return string + * The name of the bundle this field instance is attached to. + */ + public function targetBundle(); + }