function Comment::bundleFieldDefinitions

Same name and namespace in other branches
  1. 9 core/modules/comment/src/Entity/Comment.php \Drupal\comment\Entity\Comment::bundleFieldDefinitions()
  2. 8.9.x core/modules/comment/src/Entity/Comment.php \Drupal\comment\Entity\Comment::bundleFieldDefinitions()
  3. 11.x core/modules/comment/src/Entity/Comment.php \Drupal\comment\Entity\Comment::bundleFieldDefinitions()

Overrides ContentEntityBase::bundleFieldDefinitions

File

core/modules/comment/src/Entity/Comment.php, line 329

Class

Comment
Defines the comment entity class.

Namespace

Drupal\comment\Entity

Code

public static function bundleFieldDefinitions(EntityTypeInterface $entity_type, $bundle, array $base_field_definitions) {
  if ($comment_type = CommentType::load($bundle)) {
    $fields['entity_id'] = clone $base_field_definitions['entity_id'];
    $fields['entity_id']->setSetting('target_type', $comment_type->getTargetEntityTypeId());
    return $fields;
  }
  return [];
}

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