ConfigFieldMapper.php in Drupal 10
File
core/modules/config_translation/src/ConfigFieldMapper.php
View source
<?php
namespace Drupal\config_translation;
use Drupal\Core\Config\Entity\ConfigEntityInterface;
class ConfigFieldMapper extends ConfigEntityMapper {
protected $entity;
public function getBaseRouteParameters() {
$parameters = parent::getBaseRouteParameters();
$base_entity_info = $this->entityTypeManager
->getDefinition($this->pluginDefinition['base_entity_type']);
$bundle_parameter_key = $base_entity_info
->getBundleEntityType() ?: 'bundle';
$parameters[$bundle_parameter_key] = $this->entity
->getTargetBundle();
return $parameters;
}
public function getOverviewRouteName() {
return 'entity.field_config.config_translation_overview.' . $this->pluginDefinition['base_entity_type'];
}
public function getTypeLabel() {
$base_entity_info = $this->entityTypeManager
->getDefinition($this->pluginDefinition['base_entity_type']);
return $this
->t('@label fields', [
'@label' => $base_entity_info
->getLabel(),
]);
}
public function setEntity(ConfigEntityInterface $entity) {
if (parent::setEntity($entity)) {
$field_storage = $this->entity
->getFieldStorageDefinition();
$entity_type_info = $this->entityTypeManager
->getDefinition($field_storage
->getEntityTypeId());
$this
->addConfigName($entity_type_info
->getConfigPrefix() . '.' . $field_storage
->id());
return TRUE;
}
return FALSE;
}
}