function CommentManager::getFields

Same name and namespace in other branches
  1. 9 core/modules/comment/src/CommentManager.php \Drupal\comment\CommentManager::getFields()
  2. 8.9.x core/modules/comment/src/CommentManager.php \Drupal\comment\CommentManager::getFields()
  3. 10 core/modules/comment/src/CommentManager.php \Drupal\comment\CommentManager::getFields()

File

core/modules/comment/src/CommentManager.php, line 108

Class

CommentManager
Comment manager contains common functions to manage comment fields.

Namespace

Drupal\comment

Code

public function getFields($entity_type_id) {
    $entity_type = $this->entityTypeManager
        ->getDefinition($entity_type_id);
    if (!$entity_type->entityClassImplements(FieldableEntityInterface::class)) {
        return [];
    }
    $map = $this->entityFieldManager
        ->getFieldMapByFieldType('comment');
    return $map[$entity_type_id] ?? [];
}

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