You are here

public function LingotekContentTranslationService::loadByDocumentId in Lingotek Translation 8

Same name and namespace in other branches
  1. 8.2 src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::loadByDocumentId()
  2. 4.0.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::loadByDocumentId()
  3. 3.0.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::loadByDocumentId()
  4. 3.1.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::loadByDocumentId()
  5. 3.2.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::loadByDocumentId()
  6. 3.3.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::loadByDocumentId()
  7. 3.4.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::loadByDocumentId()
  8. 3.5.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::loadByDocumentId()
  9. 3.6.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::loadByDocumentId()
  10. 3.7.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::loadByDocumentId()
  11. 3.8.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::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 LingotekContentTranslationServiceInterface::loadByDocumentId

File

src/LingotekContentTranslationService.php, line 766
Contains \Drupal\lingotek\LingotekContentTranslationService.

Class

LingotekContentTranslationService
Service for managing Lingotek content translations.

Namespace

Drupal\lingotek

Code

public function loadByDocumentId($document_id) {
  $entity = NULL;
  $metadata = \Drupal::database()
    ->select('lingotek_content_metadata', 'lcm')
    ->fields('lcm', [
    'document_id',
    'entity_type',
    'entity_id',
  ])
    ->condition('document_id', $document_id)
    ->execute()
    ->fetchAssoc();
  if ($metadata) {
    $entity = $this->entityManager
      ->getStorage($metadata['entity_type'])
      ->load($metadata['entity_id']);
  }
  return $entity;
}