You are here

public static function LingotekContentMetadata::loadByTargetId in Lingotek Translation 4.0.x

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

Loads a Lingotek content metadata entity based on the entity type and id.

Parameters

string $target_entity_type_id: Target entity type id.

int $target_id: Entity id.

Return value

$this The Lingotek content metadata if one exists. Otherwise, returns default values.

10 calls to LingotekContentMetadata::loadByTargetId()
LingotekContentTranslationService::getLastUpdated in src/LingotekContentTranslationService.php
Gets the 'updated date' time metadata for the given entity.
LingotekContentTranslationService::getLastUploaded in src/LingotekContentTranslationService.php
Gets the 'initial upload' time metadata for the given entity.
LingotekContentTranslationService::setDocumentId in src/LingotekContentTranslationService.php
Sets the Lingotek document id for a given entity.
LingotekContentTranslationService::setJobId in src/LingotekContentTranslationService.php
Sets the job ID of a given entity.
LingotekContentTranslationService::setLastUpdated in src/LingotekContentTranslationService.php
Updates the 'updated date' time metadata to the current request time.

... See full list

File

src/Entity/LingotekContentMetadata.php, line 102

Class

LingotekContentMetadata
Defines the Lingotek content metadata entity.

Namespace

Drupal\lingotek\Entity

Code

public static function loadByTargetId($target_entity_type_id, $target_id) {
  $metadata = NULL;
  if ($target_entity_type_id == NULL || $target_id == NULL) {
    return NULL;
  }
  $entity_query = \Drupal::entityQuery('lingotek_content_metadata');
  $entity_query
    ->condition('content_entity_type_id', $target_entity_type_id)
    ->condition('content_entity_id', $target_id);
  $result = $entity_query
    ->execute();
  if (!empty($result)) {
    $metadata = self::load(reset($result));
  }
  if ($metadata === NULL) {
    $metadata = new static([
      'content_entity_type_id' => $target_entity_type_id,
      'content_entity_id' => $target_id,
    ], 'lingotek_content_metadata');
  }
  return $metadata;
}