ConfigFieldMapper::setEntity

public ConfigFieldMapper::setEntity(ConfigEntityInterface $entity)

Sets the entity instance for this mapper.

This method can only be invoked when the concrete entity is known, that is in a request for an entity translation path. After this method is called, the mapper is fully populated with the proper display title and configuration names to use to check permissions or display a translation screen.

Parameters

\Drupal\Core\Config\Entity\ConfigEntityInterface $entity: The configuration entity to set.

Return value

bool TRUE, if the entity was set successfully; FALSE otherwise.

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->entityManager->getDefinition($field_storage->getEntityTypeId());
    $this->addConfigName($entity_type_info->getConfigPrefix() . '.' . $field_storage->id());
    return TRUE;
  }
  return FALSE;
}
doc_Drupal
2016-10-29 08:53:22
Comments
Leave a Comment

Please login to continue.