X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fconfig_translation%2Fsrc%2FConfigFieldMapper.php;fp=web%2Fcore%2Fmodules%2Fconfig_translation%2Fsrc%2FConfigFieldMapper.php;h=c0e085f11537ef3e131c1960bf881c95afbd21e5;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hp=0000000000000000000000000000000000000000;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad;p=yaffs-website diff --git a/web/core/modules/config_translation/src/ConfigFieldMapper.php b/web/core/modules/config_translation/src/ConfigFieldMapper.php new file mode 100644 index 000000000..c0e085f11 --- /dev/null +++ b/web/core/modules/config_translation/src/ConfigFieldMapper.php @@ -0,0 +1,68 @@ +entityManager->getDefinition($this->pluginDefinition['base_entity_type']); + $bundle_parameter_key = $base_entity_info->getBundleEntityType() ?: 'bundle'; + $parameters[$bundle_parameter_key] = $this->entity->getTargetBundle(); + return $parameters; + } + + /** + * {@inheritdoc} + */ + public function getOverviewRouteName() { + return 'entity.field_config.config_translation_overview.' . $this->pluginDefinition['base_entity_type']; + } + + /** + * {@inheritdoc} + */ + public function getTypeLabel() { + $base_entity_info = $this->entityManager->getDefinition($this->pluginDefinition['base_entity_type']); + return $this->t('@label fields', ['@label' => $base_entity_info->getLabel()]); + } + + /** + * {@inheritdoc} + */ + public function setEntity(ConfigEntityInterface $entity) { + if (parent::setEntity($entity)) { + + // Field storage config can also contain translatable values. Add the name + // of the config as well to the list of configs for this entity. + /** @var \Drupal\field\FieldStorageConfigInterface $field_storage */ + $field_storage = $this->entity->getFieldStorageDefinition(); + /** @var \Drupal\Core\Config\Entity\ConfigEntityTypeInterface $entity_type_info */ + $entity_type_info = $this->entityManager->getDefinition($field_storage->getEntityTypeId()); + $this->addConfigName($entity_type_info->getConfigPrefix() . '.' . $field_storage->id()); + return TRUE; + } + return FALSE; + } + +}