public function SubscriberTracker::getEntityByRemoteIdAndHash in Acquia Content Hub 8.2
Get a local entity by its remote uuid if hashes match.
Parameters
string $uuid: The remote uuid of the entity to load.
string|null $hash: The expected hash of the entity (Currently unused).
Return value
\Drupal\Core\Entity\EntityInterface|null The loaded entity if found
Throws
\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
\Drupal\Component\Plugin\Exception\PluginNotFoundException
File
- modules/
acquia_contenthub_subscriber/ src/ SubscriberTracker.php, line 188
Class
- SubscriberTracker
- Subscriber Tracker database table methods.
Namespace
Drupal\acquia_contenthub_subscriberCode
public function getEntityByRemoteIdAndHash($uuid, $hash = NULL) {
$query = $this->database
->select(self::IMPORT_TRACKING_TABLE, 't')
->fields('t', [
'entity_type',
'entity_id',
]);
$query
->condition('entity_uuid', $uuid);
if (NULL !== $hash) {
$query
->condition('hash', $hash);
}
$result = $query
->execute()
->fetchObject();
if ($result && $result->entity_type && $result->entity_id) {
return \Drupal::entityTypeManager()
->getStorage($result->entity_type)
->load($result->entity_id);
}
}