function _comment_entity_uses_integer_id

_comment_entity_uses_integer_id($entity_type_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.

File

core/modules/comment/comment.module, line 410
Enables users to comment on published content.

Code

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

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!modules!comment!comment.module/function/_comment_entity_uses_integer_id/8.1.x