You are here

public function LingotekConfigMetadata::getConfigMapper in Lingotek Translation 3.4.x

Same name and namespace in other branches
  1. 8 src/Entity/LingotekConfigMetadata.php \Drupal\lingotek\Entity\LingotekConfigMetadata::getConfigMapper()
  2. 8.2 src/Entity/LingotekConfigMetadata.php \Drupal\lingotek\Entity\LingotekConfigMetadata::getConfigMapper()
  3. 4.0.x src/Entity/LingotekConfigMetadata.php \Drupal\lingotek\Entity\LingotekConfigMetadata::getConfigMapper()
  4. 3.0.x src/Entity/LingotekConfigMetadata.php \Drupal\lingotek\Entity\LingotekConfigMetadata::getConfigMapper()
  5. 3.1.x src/Entity/LingotekConfigMetadata.php \Drupal\lingotek\Entity\LingotekConfigMetadata::getConfigMapper()
  6. 3.2.x src/Entity/LingotekConfigMetadata.php \Drupal\lingotek\Entity\LingotekConfigMetadata::getConfigMapper()
  7. 3.3.x src/Entity/LingotekConfigMetadata.php \Drupal\lingotek\Entity\LingotekConfigMetadata::getConfigMapper()
  8. 3.5.x src/Entity/LingotekConfigMetadata.php \Drupal\lingotek\Entity\LingotekConfigMetadata::getConfigMapper()
  9. 3.6.x src/Entity/LingotekConfigMetadata.php \Drupal\lingotek\Entity\LingotekConfigMetadata::getConfigMapper()
  10. 3.7.x src/Entity/LingotekConfigMetadata.php \Drupal\lingotek\Entity\LingotekConfigMetadata::getConfigMapper()
  11. 3.8.x src/Entity/LingotekConfigMetadata.php \Drupal\lingotek\Entity\LingotekConfigMetadata::getConfigMapper()

Gets the config mapper for this metadata.

Return value

\Drupal\config_translation\ConfigMapperInterface The config mapper this metadata is related to.

File

src/Entity/LingotekConfigMetadata.php, line 287

Class

LingotekConfigMetadata
Defines the Lingotek config metadata entity.

Namespace

Drupal\lingotek\Entity

Code

public function getConfigMapper() {
  $mapper = NULL;

  /** @var \Drupal\config_translation\ConfigMapperInterface[] $mappers */
  $mappers = \Drupal::service('plugin.manager.config_translation.mapper')
    ->getMappers();
  $name = $this
    ->getDependencyName();
  $config_mapper_id = $this
    ->getMapperIdForName($name);
  if (isset($mappers[$config_mapper_id])) {
    $mapper = $mappers[$config_mapper_id];
  }
  else {
    list($entity_type, $entity_id) = explode('.', $this->config_name, 2);
    if (isset($mappers[$entity_type])) {
      $storage = $this
        ->entityTypeManager()
        ->getStorage($entity_type);
      $entity = $storage
        ->load($entity_id);
      $mapper = clone $mappers[$entity_type];
      $mapper
        ->setEntity($entity);
    }
  }
  return $mapper;
}