public function GlobalReferenceManager::createEntityGlobalId in Content Synchronizer 8
Same name and namespace in other branches
- 8.2 src/Service/GlobalReferenceManager.php \Drupal\content_synchronizer\Service\GlobalReferenceManager::createEntityGlobalId()
- 3.x src/Service/GlobalReferenceManager.php \Drupal\content_synchronizer\Service\GlobalReferenceManager::createEntityGlobalId()
Create GID.
Parameters
\Drupal\Core\Entity\Entity $entity: The entity.
Return value
string The gid.
File
- src/
Service/ GlobalReferenceManager.php, line 59
Class
- GlobalReferenceManager
- The global reference manager.
Namespace
Drupal\content_synchronizer\ServiceCode
public function createEntityGlobalId(Entity $entity) {
$gid = (int) (microtime(TRUE) * 100) . '.' . $entity
->getEntityTypeId() . '.' . $entity
->id();
$data = [
self::FIELD_GID => $gid,
self::FIELD_ENTITY_ID => $entity
->id(),
self::FIELD_ENTITY_TYPE => $entity
->getEntityTypeId(),
];
\Drupal::database()
->insert(self::GID_TABLE_NAME)
->fields(array_keys($data))
->values($data)
->execute();
return $gid;
}