3 namespace Drupal\config_translation;
5 use Drupal\Core\Config\Entity\ConfigEntityInterface;
8 * Configuration mapper for fields.
10 * On top of plugin definition values on ConfigEntityMapper, the plugin
11 * definition for field mappers are required to contain the following
13 * - base_entity_type: The name of the entity type the fields are attached to.
15 class ConfigFieldMapper extends ConfigEntityMapper {
18 * Loaded entity instance to help produce the translation interface.
20 * @var \Drupal\field\FieldConfigInterface
27 public function getBaseRouteParameters() {
28 $parameters = parent::getBaseRouteParameters();
29 $base_entity_info = $this->entityManager->getDefinition($this->pluginDefinition['base_entity_type']);
30 $bundle_parameter_key = $base_entity_info->getBundleEntityType() ?: 'bundle';
31 $parameters[$bundle_parameter_key] = $this->entity->getTargetBundle();
38 public function getOverviewRouteName() {
39 return 'entity.field_config.config_translation_overview.' . $this->pluginDefinition['base_entity_type'];
45 public function getTypeLabel() {
46 $base_entity_info = $this->entityManager->getDefinition($this->pluginDefinition['base_entity_type']);
47 return $this->t('@label fields', ['@label' => $base_entity_info->getLabel()]);
53 public function setEntity(ConfigEntityInterface $entity) {
54 if (parent::setEntity($entity)) {
56 // Field storage config can also contain translatable values. Add the name
57 // of the config as well to the list of configs for this entity.
58 /** @var \Drupal\field\FieldStorageConfigInterface $field_storage */
59 $field_storage = $this->entity->getFieldStorageDefinition();
60 /** @var \Drupal\Core\Config\Entity\ConfigEntityTypeInterface $entity_type_info */
61 $entity_type_info = $this->entityManager->getDefinition($field_storage->getEntityTypeId());
62 $this->addConfigName($entity_type_info->getConfigPrefix() . '.' . $field_storage->id());