function ConfigEntityMapper::setEntity

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

Overrides ConfigEntityMapperInterface::setEntity

3 calls to ConfigEntityMapper::setEntity()
ConfigEntityMapper::populateFromRouteMatch in core/modules/config_translation/src/ConfigEntityMapper.php
Populate the config mapper with route match data.
ConfigFieldMapper::setEntity in core/modules/config_translation/src/ConfigFieldMapper.php
Sets the entity instance for this mapper.
NodeTypeMapper::setEntity in core/modules/node/src/ConfigTranslation/NodeTypeMapper.php
Sets the entity instance for this mapper.
2 methods override ConfigEntityMapper::setEntity()
ConfigFieldMapper::setEntity in core/modules/config_translation/src/ConfigFieldMapper.php
Sets the entity instance for this mapper.
NodeTypeMapper::setEntity in core/modules/node/src/ConfigTranslation/NodeTypeMapper.php
Sets the entity instance for this mapper.

File

core/modules/config_translation/src/ConfigEntityMapper.php, line 127

Class

ConfigEntityMapper
Configuration mapper for configuration entities.

Namespace

Drupal\config_translation

Code

public function setEntity(ConfigEntityInterface $entity) {
    if (isset($this->entity)) {
        return FALSE;
    }
    $this->entity = $entity;
    // Add the list of configuration IDs belonging to this entity. We add on a
    // possibly existing list of names. This allows modules to alter the entity
    // page with more names if form altering added more configuration to an
    // entity. This is not a Drupal 8 best practice (ideally the configuration
    // would have pluggable components), but this may happen as well.
    
    /** @var \Drupal\Core\Config\Entity\ConfigEntityTypeInterface $entity_type_info */
    $entity_type_info = $this->entityTypeManager
        ->getDefinition($this->entityType);
    $this->addConfigName($entity_type_info->getConfigPrefix() . '.' . $entity->id());
    return TRUE;
}

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