public function LingotekConfigTranslationService::loadByDocumentId in Lingotek Translation 8
Same name and namespace in other branches
- 8.2 src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::loadByDocumentId()
- 4.0.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::loadByDocumentId()
- 3.0.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::loadByDocumentId()
- 3.1.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::loadByDocumentId()
- 3.2.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::loadByDocumentId()
- 3.3.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::loadByDocumentId()
- 3.4.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::loadByDocumentId()
- 3.5.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::loadByDocumentId()
- 3.6.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::loadByDocumentId()
- 3.7.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::loadByDocumentId()
- 3.8.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::loadByDocumentId()
Loads the entity with the given document id.
Parameters
string $document_id: The document id.
Return value
ContentEntityInterface The entity with the given document id.
Overrides LingotekConfigTranslationServiceInterface::loadByDocumentId
File
- src/
LingotekConfigTranslationService.php, line 997 - Contains \Drupal\lingotek\LingotekConfigTranslationService.
Class
- LingotekConfigTranslationService
- Service for managing Lingotek configuration translations.
Namespace
Drupal\lingotekCode
public function loadByDocumentId($document_id) {
// We cannot use a mapping table as in content, because config can be staged.
$entity = NULL;
// Check config first.
$config_mappers = array_filter($this->mappers, function ($mapper) {
return $mapper instanceof ConfigNamesMapper && !$mapper instanceof ConfigEntityMapper && !$mapper instanceof ConfigFieldMapper;
});
foreach ($config_mappers as $mapper_id => $mapper) {
if ($this
->getConfigDocumentId($mapper) === $document_id) {
return $mapper;
}
}
// If we failed, check config entities.
foreach ($this->mappers as $mapper_id => $mapper) {
if (!isset($config_mappers[$mapper_id])) {
$id = NULL;
if (substr($mapper_id, -7) == '_fields') {
// Hack for fields, the entity is field config.
$mapper_id = 'field_config';
}
$id = \Drupal::service('entity.query')
->get('lingotek_config_metadata')
->condition('document_id', $document_id)
->execute();
if (!empty($id)) {
list($mapper_id, $entity_id) = explode('.', reset($id), 2);
return $this->entityManager
->getStorage($mapper_id)
->load($entity_id);
}
}
}
return NULL;
}