Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Comment.php

function Comment::preCreate

Overrides EntityBase::preCreate

File

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

Class

Comment
Defines the comment entity class.

Namespace

Drupal\comment\Entity

Code

public static function preCreate(EntityStorageInterface $storage, array &$values) {
    if (empty($values['comment_type']) && !empty($values['field_name']) && !empty($values['entity_type'])) {
        $fields = \Drupal::service('entity_field.manager')->getFieldStorageDefinitions($values['entity_type']);
        $values['comment_type'] = $fields[$values['field_name']]->getSetting('comment_type');
    }
}
RSS feed
Powered by Drupal