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

Breadcrumb

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

function CommentHooks::fieldConfigCreate

Implements hook_ENTITY_TYPE_create() for 'field_config'.

File

core/modules/comment/src/Hook/CommentHooks.php, line 114

Class

CommentHooks
Hook implementations for comment.

Namespace

Drupal\comment\Hook

Code

public function fieldConfigCreate(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);
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal