function _comment_entity_uses_integer_id

Same name in other branches
  1. 9 core/modules/comment/comment.module \_comment_entity_uses_integer_id()
  2. 10 core/modules/comment/comment.module \_comment_entity_uses_integer_id()
  3. 11.x core/modules/comment/comment.module \_comment_entity_uses_integer_id()

Determines if an entity type is using 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.

2 calls to _comment_entity_uses_integer_id()
comment_field_storage_config_insert in core/modules/comment/comment.module
Implements hook_ENTITY_TYPE_insert() for 'field_storage_config'.
comment_form_field_ui_field_storage_add_form_alter in core/modules/comment/comment.module
Implements hook_form_FORM_ID_alter() for field_ui_field_storage_add_form.

File

core/modules/comment/comment.module, line 429

Code

function _comment_entity_uses_integer_id($entity_type_id) {
    $entity_type = \Drupal::entityTypeManager()->getDefinition($entity_type_id);
    $entity_type_id_key = $entity_type->getKey('id');
    if ($entity_type_id_key === FALSE) {
        return FALSE;
    }
    $field_definitions = \Drupal::service('entity_field.manager')->getBaseFieldDefinitions($entity_type->id());
    $entity_type_id_definition = $field_definitions[$entity_type_id_key];
    return $entity_type_id_definition->getType() === 'integer';
}

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