private function ImportEntityManager::trackImportedEntity in Acquia Content Hub 8
Save this entity in the Tracking table.
Parameters
\Drupal\acquia_contenthub\ContentHubEntityDependency $contenthub_entity: The Content Hub Entity.
Return value
bool TRUE if entity is new, FALSE otherwise.
Throws
\Drupal\Core\Entity\EntityStorageException
1 call to ImportEntityManager::trackImportedEntity()
- ImportEntityManager::importRemoteEntityNoDependencies in src/
ImportEntityManager.php - Saves an Entity without taking care of dependencies.
File
- src/
ImportEntityManager.php, line 830
Class
- ImportEntityManager
- Provides a service for managing imported entities' actions.
Namespace
Drupal\acquia_contenthubCode
private function trackImportedEntity(ContentHubEntityDependency $contenthub_entity) {
$cdf = (array) $contenthub_entity
->getRawEntity();
$imported_entity = $this->contentHubEntitiesTracking
->loadImportedByUuid($cdf['uuid']);
// If already exist, update some fields and exit.
if ($imported_entity) {
// Set status to "auto-update" only when the entity is independent.
if (!$imported_entity
->isDependent()) {
$imported_entity
->setAutoUpdate();
}
$imported_entity
->setModified($cdf['modified']);
$this
->saveImportedEntity();
return FALSE;
}
// If the entity is new, create a new imported entity.
$entity = $this->entityRepository
->loadEntityByUuid($cdf['type'], $cdf['uuid']);
if ($entity) {
$this->contentHubEntitiesTracking
->setImportedEntity($cdf['type'], $entity
->id(), $cdf['uuid'], $cdf['modified'], $cdf['origin']);
if ($contenthub_entity
->isEntityDependent()) {
$this->contentHubEntitiesTracking
->setDependent();
}
$this
->saveImportedEntity();
return TRUE;
}
// We should never reach this far.
$this->loggerFactory
->get('acquia_contenthub')
->error('Error trying to track imported entity with uuid=%uuid, type=%type. Check if the entity exists and is being tracked properly.', [
'%type' => $cdf['type'],
'%uuid' => $cdf['uuid'],
]);
return FALSE;
}