function ConfigEntityMapper::setEntity
Same name in other branches
- 8.9.x core/modules/config_translation/src/ConfigEntityMapper.php \Drupal\config_translation\ConfigEntityMapper::setEntity()
- 10 core/modules/config_translation/src/ConfigEntityMapper.php \Drupal\config_translation\ConfigEntityMapper::setEntity()
- 11.x core/modules/config_translation/src/ConfigEntityMapper.php \Drupal\config_translation\ConfigEntityMapper::setEntity()
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.
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 142
Class
- ConfigEntityMapper
- Configuration mapper for configuration entities.
Namespace
Drupal\config_translationCode
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.