You are here

public function GlobalReferenceManager::getEntityGlobalId in Content Synchronizer 8

Same name and namespace in other branches
  1. 8.2 src/Service/GlobalReferenceManager.php \Drupal\content_synchronizer\Service\GlobalReferenceManager::getEntityGlobalId()
  2. 3.x src/Service/GlobalReferenceManager.php \Drupal\content_synchronizer\Service\GlobalReferenceManager::getEntityGlobalId()

Get the global id of the entity.

Parameters

\Drupal\Core\Entity\Entity $entity: The entity.

Return value

string The gid.

File

src/Service/GlobalReferenceManager.php, line 37

Class

GlobalReferenceManager
The global reference manager.

Namespace

Drupal\content_synchronizer\Service

Code

public function getEntityGlobalId(Entity $entity) {
  $query = \Drupal::database()
    ->select(self::GID_TABLE_NAME)
    ->fields(self::GID_TABLE_NAME, [
    self::FIELD_GID,
  ])
    ->condition(self::FIELD_ENTITY_TYPE, $entity
    ->getEntityTypeId())
    ->condition(self::FIELD_ENTITY_ID, $entity
    ->id());
  if ($result = $query
    ->execute()
    ->fetchField()) {
    return $result;
  }
  return NULL;
}