function _comment_entity_uses_integer_id in Drupal 9
Same name and namespace in other branches
- 8 core/modules/comment/comment.module \_comment_entity_uses_integer_id()
- 10 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.
3 calls to _comment_entity_uses_integer_id()
- CommentTypeForm::entityTypeSupportsComments in core/
modules/ comment/ src/ CommentTypeForm.php - Wraps _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 342 - Enables users to comment on published content.
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';
}