function WorkspaceTracker::getIdField

Determines the target ID field name for an entity type.

@internal

Parameters

string $entity_type_id: The entity type ID.

Return value

string The name of the workspace association target ID field.

5 calls to WorkspaceTracker::getIdField()
QueryTrait::prepare in core/modules/workspaces/src/EntityQuery/QueryTrait.php
Tables::addWorkspaceTrackerJoin in core/modules/workspaces/src/EntityQuery/Tables.php
Adds a join to the 'workspace_association' table for an entity base table.
ViewsOperations::ensureWorkspaceAssociationTable in core/modules/workspaces/src/Hook/ViewsOperations.php
Adds the 'workspace_association' table to a views query.
WorkspaceAssociation::getIdField in core/modules/workspaces/src/WorkspaceAssociation.php
Determines the target ID field name for an entity type.
workspaces_update_11302 in core/modules/workspaces/workspaces.install
Populate the 'workspace_association_revision' table.

File

core/modules/workspaces/src/WorkspaceTracker.php, line 550

Class

WorkspaceTracker
Provides a class for CRUD operations on workspace associations.

Namespace

Drupal\workspaces

Code

public static function getIdField(string $entity_type_id) : string {
  static $id_field_map = [];
  if (!isset($id_field_map[$entity_type_id])) {
    $id_field = \Drupal::entityTypeManager()->getDefinition($entity_type_id)
      ->getKey('id');
    $field_map = \Drupal::service('entity_field.manager')->getFieldMap()[$entity_type_id];
    $id_field_map[$entity_type_id] = $field_map[$id_field]['type'] !== 'integer' ? 'target_entity_id_string' : 'target_entity_id';
  }
  return $id_field_map[$entity_type_id];
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.