function ConfigFieldMapper::setEntity

Same name in other branches
  1. 9 core/modules/config_translation/src/ConfigFieldMapper.php \Drupal\config_translation\ConfigFieldMapper::setEntity()
  2. 8.9.x core/modules/config_translation/src/ConfigFieldMapper.php \Drupal\config_translation\ConfigFieldMapper::setEntity()
  3. 10 core/modules/config_translation/src/ConfigFieldMapper.php \Drupal\config_translation\ConfigFieldMapper::setEntity()

Overrides ConfigEntityMapper::setEntity

File

core/modules/config_translation/src/ConfigFieldMapper.php, line 53

Class

ConfigFieldMapper
Configuration mapper for fields.

Namespace

Drupal\config_translation

Code

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->entityTypeManager
            ->getDefinition($field_storage->getEntityTypeId());
        $this->addConfigName($entity_type_info->getConfigPrefix() . '.' . $field_storage->id());
        return TRUE;
    }
    return FALSE;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.