You are here

protected function ContentHubEntitiesTracking::loadByDrupalEntity in Acquia Content Hub 8

Loads a record using Drupal entity key information.

Parameters

string $entity_type: The Entity type.

string $entity_id: The entity ID.

Return value

\Drupal\acquia_contenthub\ContentHubEntitiesTracking|bool This ContentHubEntitiesTracking object if succeeds, FALSE otherwise.

3 calls to ContentHubEntitiesTracking::loadByDrupalEntity()
ContentHubEntitiesTracking::loadExportedByDrupalEntity in src/ContentHubEntitiesTracking.php
Loads an Exported Entity tracking record by entity key information.
ContentHubEntitiesTracking::loadImportedByDrupalEntity in src/ContentHubEntitiesTracking.php
Loads an Imported Entity tracking record by entity key information.
ContentHubEntitiesTracking::save in src/ContentHubEntitiesTracking.php
Saves a record of an imported entity.

File

src/ContentHubEntitiesTracking.php, line 661

Class

ContentHubEntitiesTracking
Tracks in a table the list of all entities imported from Content Hub.

Namespace

Drupal\acquia_contenthub

Code

protected function loadByDrupalEntity($entity_type, $entity_id) {

  // Utilize local cache to skip database calls.
  if (isset($this->cachedTrackingEntities[$entity_type][$entity_id])) {
    $tracking_entity = $this->cachedTrackingEntities[$entity_type][$entity_id];
    $this
      ->setTrackingEntity($tracking_entity->entity_type, $tracking_entity->entity_id, $tracking_entity->entity_uuid, $tracking_entity->modified, $tracking_entity->origin, $tracking_entity->status_export, $tracking_entity->status_import);
    return $this;
  }
  $result = $this->database
    ->select(self::TABLE, 'ci')
    ->fields('ci')
    ->condition('entity_type', $entity_type)
    ->condition('entity_id', $entity_id)
    ->execute()
    ->fetchAssoc();
  if (!$result) {
    return FALSE;
  }
  $this
    ->setTrackingEntity($result['entity_type'], $result['entity_id'], $result['entity_uuid'], $result['modified'], $result['origin'], $result['status_export'], $result['status_import']);
  return $this;
}