You are here

public static function DynamicEntityReferenceItem::entityHasIntegerId in Dynamic Entity Reference 8.2

Same name and namespace in other branches
  1. 8 src/Plugin/Field/FieldType/DynamicEntityReferenceItem.php \Drupal\dynamic_entity_reference\Plugin\Field\FieldType\DynamicEntityReferenceItem::entityHasIntegerId()

Determines if an entity type has an integer-based ID definition.

Parameters

string $entity_type_id: The ID the represents the entity type.

Return value

bool Returns TRUE if the entity type has an integer-based ID definition and FALSE otherwise.

5 calls to DynamicEntityReferenceItem::entityHasIntegerId()
DynamicEntityReferenceItem::getTargetIdColumnName in src/Plugin/Field/FieldType/DynamicEntityReferenceItem.php
Generates a column name for a target_id property.
dynamic_entity_reference_field_views_data in ./dynamic_entity_reference.views.inc
Implements hook_field_views_data().
dynamic_entity_reference_views_data in ./dynamic_entity_reference.views.inc
Implements hook_views_data().
dynamic_entity_reference_views_data_alter in ./dynamic_entity_reference.views.inc
Implements hook_views_data_alter().
Tables::addNextBaseTable in src/Query/Tables.php
Add the next entity base table.

File

src/Plugin/Field/FieldType/DynamicEntityReferenceItem.php, line 671

Class

DynamicEntityReferenceItem
Defines the 'dynamic_entity_reference' entity field type.

Namespace

Drupal\dynamic_entity_reference\Plugin\Field\FieldType

Code

public static function entityHasIntegerId($entity_type_id) {
  $entity_type = \Drupal::entityTypeManager()
    ->getDefinition($entity_type_id);

  // Make sure entity type is a content entity type.
  if (!$entity_type instanceof ContentEntityTypeInterface) {
    return FALSE;
  }

  // Make sure entity type has an id.
  if (!$entity_type
    ->hasKey('id')) {
    return FALSE;
  }

  /** @var \Drupal\Core\Field\FieldDefinitionInterface[] $field_definitions */
  $field_definitions = \Drupal::service('entity_field.manager')
    ->getBaseFieldDefinitions($entity_type_id);
  $entity_type_id_definition = $field_definitions[$entity_type
    ->getKey('id')];
  return $entity_type_id_definition
    ->getType() === 'integer';
}