function comment_field_config_create

Same name in other branches
  1. 9 core/modules/comment/comment.module \comment_field_config_create()
  2. 10 core/modules/comment/comment.module \comment_field_config_create()
  3. 11.x core/modules/comment/comment.module \comment_field_config_create()

Implements hook_ENTITY_TYPE_create() for 'field_config'.

File

core/modules/comment/comment.module, line 157

Code

function comment_field_config_create(FieldConfigInterface $field) {
    if ($field->getType() == 'comment' && !$field->isSyncing()) {
        // Assign default values for the field.
        $default_value = $field->getDefaultValueLiteral();
        $default_value += [
            [],
        ];
        $default_value[0] += [
            'status' => CommentItemInterface::OPEN,
            'cid' => 0,
            'last_comment_timestamp' => 0,
            'last_comment_name' => '',
            'last_comment_uid' => 0,
            'comment_count' => 0,
        ];
        $field->setDefaultValue($default_value);
    }
}

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