diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index 08e938d..804e4a1 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -156,27 +156,6 @@ function comment_theme() { } /** - * Implements hook_ENTITY_TYPE_create() for 'field_instance_config'. - */ -function comment_field_instance_config_create(FieldInstanceConfigInterface $instance) { - if ($instance->getType() == 'comment' && !$instance->isSyncing()) { - // Assign default values for the field instance. - if (!isset($instance->default_value)) { - $instance->default_value = array(); - } - $instance->default_value += array(array()); - $instance->default_value[0] += array( - 'status' => CommentItemInterface::OPEN, - 'cid' => 0, - 'last_comment_timestamp' => 0, - 'last_comment_name' => '', - 'last_comment_uid' => 0, - 'comment_count' => 0, - ); - } -} - -/** * Implements hook_ENTITY_TYPE_update() for 'field_instance_config'. */ function comment_field_instance_config_update(FieldInstanceConfigInterface $instance) { diff --git a/core/modules/comment/src/Plugin/Field/FieldType/CommentFieldItemList.php b/core/modules/comment/src/Plugin/Field/FieldType/CommentFieldItemList.php new file mode 100644 index 0000000..3de1bd5 --- /dev/null +++ b/core/modules/comment/src/Plugin/Field/FieldType/CommentFieldItemList.php @@ -0,0 +1,38 @@ + CommentItemInterface::OPEN, + 'cid' => 0, + 'last_comment_timestamp' => 0, + 'last_comment_name' => '', + 'last_comment_uid' => 0, + 'comment_count' => 0, + ); + } + return $default_value; + } + +} diff --git a/core/modules/comment/src/Plugin/Field/FieldType/CommentItem.php b/core/modules/comment/src/Plugin/Field/FieldType/CommentItem.php index 7fb70aa..780d207 100644 --- a/core/modules/comment/src/Plugin/Field/FieldType/CommentItem.php +++ b/core/modules/comment/src/Plugin/Field/FieldType/CommentItem.php @@ -21,7 +21,8 @@ * label = @Translation("Comments"), * description = @Translation("This field manages configuration and presentation of comments on an entity."), * default_widget = "comment_default", - * default_formatter = "comment_default" + * default_formatter = "comment_default", + * list_class = "\Drupal\comment\Plugin\Field\FieldType\CommentFieldItemList" * ) */ class CommentItem extends FieldItemBase implements CommentItemInterface { @@ -169,20 +170,6 @@ public function instanceSettingsForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function __get($name) { - if ($name == 'status' && !isset($this->values[$name])) { - // Get default value from field instance when no data saved in entity. - $field_default_values = $this->getFieldDefinition()->getDefaultValue($this->getEntity()); - return $field_default_values[0]['status']; - } - else { - return parent::__get($name); - } - } - - /** - * {@inheritdoc} - */ public function isEmpty() { // There is always a value for this field, it is one of // CommentItemInterface::OPEN, CommentItemInterface::CLOSED or