You are here

public function LingotekConfigMetadata::getConfigMapper in Lingotek Translation 8

Same name and namespace in other branches
  1. 8.2 src/Entity/LingotekConfigMetadata.php \Drupal\lingotek\Entity\LingotekConfigMetadata::getConfigMapper()
  2. 4.0.x src/Entity/LingotekConfigMetadata.php \Drupal\lingotek\Entity\LingotekConfigMetadata::getConfigMapper()
  3. 3.0.x src/Entity/LingotekConfigMetadata.php \Drupal\lingotek\Entity\LingotekConfigMetadata::getConfigMapper()
  4. 3.1.x src/Entity/LingotekConfigMetadata.php \Drupal\lingotek\Entity\LingotekConfigMetadata::getConfigMapper()
  5. 3.2.x src/Entity/LingotekConfigMetadata.php \Drupal\lingotek\Entity\LingotekConfigMetadata::getConfigMapper()
  6. 3.3.x src/Entity/LingotekConfigMetadata.php \Drupal\lingotek\Entity\LingotekConfigMetadata::getConfigMapper()
  7. 3.4.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

ConfigMapperInterface The config mapper this metadata is related to.

File

src/Entity/LingotekConfigMetadata.php, line 185

Class

LingotekConfigMetadata
Defines the Lingotek config metadata entity.

Namespace

Drupal\lingotek\Entity

Code

public function getConfigMapper() {
  $mapper = NULL;

  /** @var 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
        ->entityManager()
        ->getStorage($entity_type);
      $entity = $storage
        ->load($entity_id);
      $mapper = clone $mappers[$entity_type];
      $mapper
        ->setEntity($entity);
    }
  }
  return $mapper;
}