diff --git a/core/modules/comment/comment.admin.inc b/core/modules/comment/comment.admin.inc index 2bfce3d..ff71616 100644 --- a/core/modules/comment/comment.admin.inc +++ b/core/modules/comment/comment.admin.inc @@ -13,48 +13,77 @@ */ function comment_overview_bundles() { $header = array( - t('Field name'), - t('Used in'), - array( - 'data' => t('Operations'), - 'colspan' => (module_exists('field_ui') ? '4' : '2') - ) + 'field_name' => t('Field name'), + 'usage' => array( + 'data' => t('Used in'), + 'class' => array(RESPONSIVE_PRIORITY_MEDIUM), + ), ); - $rows = array(); - foreach (comment_get_comment_fields() as $field_name => $field_info) { - foreach ($field_info['bundles'] as $entity_type => $field_bundles) { - $bundles = array_intersect_key(entity_get_bundles($entity_type), array_flip($field_bundles)); + $field_ui = module_exists('field_ui'); + if ($field_ui) { + $header['operations'] = t('Operations'); + } - foreach ($bundles as $bundle => $bundle_info) { - if (!isset($rows[$field_name])) { - $rows[$field_name]['class'] = $field_info['locked'] ? array('menu-disabled') : array(''); - $rows[$field_name]['data']['label'] = $field_info['locked'] ? t('@field_name (Locked)', array('@field_name' => $field_name)) : $field_name; - } + $entity_bundles = entity_get_bundles(); + $entity_types = drupal_container()->get('plugin.manager.entity')->getDefinitions(); + $rows = array(); - if (module_exists('field_ui') && $path = field_ui_bundle_admin_path($entity_type, $bundle)) { - $rows[$field_name]['data']['usage'][] = l($bundle_info['label'], $path . '/fields'); - } - else { - $rows[$field_name]['data']['usage'][] = $bundle_info['label']; - } + foreach (comment_get_comment_fields() as $field_name => $field_info_map) { + $field_info = field_info_field($field_name); + // Initialize the row. + $rows[$field_name]['class'] = $field_info['locked'] ? array('field-disabled') : array(''); + $rows[$field_name]['data']['field_name']['data'] = $field_info['locked'] ? t('@field_name (Locked)', array('@field_name' => $field_name)) : $field_name; - if (module_exists('field_ui')) { - $name = strtr($field_name, '_', '-'); - $rows[$field_name]['data']['fields'] = l(t('manage fields'), 'admin/structure/comments/' . $name . '/fields'); - $rows[$field_name]['data']['display'] = l(t('manage display'), 'admin/structure/comments/' . $name . '/display'); + $rows[$field_name]['data']['usage']['data'] = array( + '#theme' => 'item_list', + '#items' => array(), + ); + foreach ($field_info['bundles'] as $entity_type => $field_bundles) { + $bundles = array(); + foreach ($field_bundles as $bundle) { + if (isset($entity_bundles[$entity_type][$bundle])) { + // Add the current instance. + if ($field_ui && $path = field_ui_bundle_admin_path($entity_type, $bundle)) { + $bundles[] = l($entity_bundles[$entity_type][$bundle]['label'], $path . '/fields'); + } + else { + $bundles[] = $entity_bundles[$entity_type][$bundle]['label']; + } } } + // Format used entity bundles. + $rows[$field_name]['data']['usage']['data']['#items'][] = t('@entity_type: !bundles', array( + '@entity_type' => $entity_types[$entity_type]['label'], + '!bundles' => implode(', ', $bundles), + )); } - $rows[$field_name]['data']['usage'] = implode(', ', $rows[$field_name]['data']['usage']); + if ($field_ui) { + // @todo Check proper permissions for operations. + $links['fields'] = array( + 'title' => t('manage fields'), + 'href' => 'admin/structure/comments/' . $field_name . '/fields', + 'weight' => 5, + ); + $links['display'] = array( + 'title' => t('manage display'), + 'href' => 'admin/structure/comments/' . $field_name . '/display', + 'weight' => 10, + ); + + $rows[$field_name]['data']['operations']['data'] = array( + '#type' => 'operations', + '#links' => $links, + ); + } } $build['overview'] = array( '#theme' => 'table', '#header' => $header, '#rows' => $rows, - '#empty' => t('No comment bundles available.'), + '#empty' => t('No comment forms available.'), ); return $build; diff --git a/core/modules/comment/comment.field.inc b/core/modules/comment/comment.field.inc index 830d1e2..270dfc8 100644 --- a/core/modules/comment/comment.field.inc +++ b/core/modules/comment/comment.field.inc @@ -16,20 +16,22 @@ function comment_field_info() { return array( 'comment' => array( 'label' => t('Comments'), - 'default_widget' => 'comment_default', 'settings' => array(), 'instance_settings' => array( 'comment' => array( 'comment' => COMMENT_OPEN, - 'comment_default_mode' => COMMENT_MODE_THREADED, - 'comment_default_per_page' => 50, + // @todo Move to formatter settings. + //'comment_default_mode' => COMMENT_MODE_THREADED, + //'comment_default_per_page' => 50, + //'comment_form_location' => COMMENT_FORM_BELOW, + // Comment form settings per field bundle. 'comment_anonymous' => COMMENT_ANONYMOUS_MAYNOT_CONTACT, 'comment_subject_field' => 1, - 'comment_form_location' => COMMENT_FORM_BELOW, 'comment_preview' => DRUPAL_OPTIONAL ) ), 'description' => t('This field manages configuration and presentation of comments on an entity'), + 'default_widget' => 'comment_default', 'default_formatter' => 'comment_default' ) ); @@ -42,7 +44,7 @@ function comment_field_instance_settings_form($field, $instance) { $settings = $instance['settings']['comment']; $form['comment'] = array( '#type' => 'details', - '#title' => t('Comment settings'), + '#title' => t('Comment form settings'), '#collapsible' => TRUE, '#collapsed' => FALSE, '#field_name' => $field['field_name'], @@ -54,27 +56,13 @@ function comment_field_instance_settings_form($field, $instance) { 'library' => array(array('comment', 'drupal.comment')), ), ); - $form['comment']['comment'] = array( - '#type' => 'select', - '#title' => t('Default comment setting for new content'), - '#default_value' => $settings['comment'], - '#options' => array( - COMMENT_OPEN => t('Open'), - COMMENT_CLOSED => t('Closed'), - COMMENT_HIDDEN => t('Hidden'), - ), - ); - $form['comment']['comment_default_mode'] = array( + // @todo Remove this settings to field defaults. + $form['comment']['comment'] = array('#type' => 'value', '#value' => $settings['comment']); + // Comment form settings. + $form['comment']['comment_subject_field'] = array( '#type' => 'checkbox', - '#title' => t('Threading'), - '#default_value' => $settings['comment_default_mode'], - '#description' => t('Show comment replies in a threaded list.'), - ); - $form['comment']['comment_default_per_page'] = array( - '#type' => 'select', - '#title' => t('Comments per page'), - '#default_value' => $settings['comment_default_per_page'], - '#options' => _comment_per_page(), + '#title' => t('Allow comment title'), + '#default_value' => $settings['comment_subject_field'], ); $form['comment']['comment_anonymous'] = array( '#type' => 'select', @@ -87,16 +75,6 @@ function comment_field_instance_settings_form($field, $instance) { ), '#access' => user_access('post comments', drupal_anonymous_user()), ); - $form['comment']['comment_subject_field'] = array( - '#type' => 'checkbox', - '#title' => t('Allow comment title'), - '#default_value' => $settings['comment_subject_field'], - ); - $form['comment']['comment_form_location'] = array( - '#type' => 'checkbox', - '#title' => t('Show reply form on the same page as comments'), - '#default_value' => $settings['comment_form_location'], - ); $form['comment']['comment_preview'] = array( '#type' => 'radios', '#title' => t('Preview comment'), @@ -129,163 +107,18 @@ function comment_instance_settings_translation_entity_process($element, $form_st } /** - * Implements hook_field_formatter_info(). - */ -function comment_field_formatter_info() { - return array( - 'comment_default' => array( - 'label' => t('Comments'), - 'field types' => array('comment'), - ), - ); -} - -/** - * Implements hook_field_widget_info(). + * Implements hook_field_widget_info_alter(). * - * @todo convert this to a WidgetPlugin. + * @todo convert this to a WidgetPlugin annotation. */ -function comment_field_widget_info() { - return array( - 'comment_default' => array( - 'label' => t('Comment'), - 'field types' => array('comment'), - 'settings' => array(), - 'behaviors' => array( - 'multiple values' => FIELD_BEHAVIOR_CUSTOM, - 'default value' => FIELD_BEHAVIOR_NONE, - ), - ), +function comment_field_widget_info_alter(&$info) { + $info['comment_default']['behaviors'] = array( + 'multiple values' => FIELD_BEHAVIOR_CUSTOM, + //'default value' => FIELD_BEHAVIOR_NONE, ); } /** - * Implements hook_field_widget_form(). - * - * @todo convert this to a WidgetPlugin. - */ -function comment_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) { - $entity = $element['#entity']; - $settings = $instance['settings']['comment']; - $element += array( - '#type' => 'details', - '#access' => user_access('administer comments'), - '#collapsible' => TRUE, - '#collapsed' => TRUE, - '#group' => 'advanced', - '#attributes' => array( - 'class' => array('comment-node-settings-form'), - ), - '#attached' => array( - 'library' => array('comment', 'drupal.comment'), - ), - '#weight' => 30, - ); - $values = reset($items); - if (empty($values)) { - $values = array( - // Default taken from instance settings. - 'comment' => $settings['comment'], - ); - } - $entity_id = $entity->id(); - $comment_count = empty($entity->comment_statistics[$field['field_name']]->comment_count) ? 0 : $entity->comment_statistics[$field['field_name']]->comment_count; - $comment_settings = ($values['comment'] == COMMENT_HIDDEN && empty($comment_count)) ? COMMENT_CLOSED : $values['comment']; - $element['comment'] = array( - '#type' => 'radios', - '#title' => t('Comments'), - '#title_display' => 'invisible', - '#default_value' => $comment_settings, - '#options' => array( - COMMENT_OPEN => t('Open'), - COMMENT_CLOSED => t('Closed'), - COMMENT_HIDDEN => t('Hidden'), - ), - COMMENT_OPEN => array( - '#description' => t('Users with the "Post comments" permission can post comments.'), - ), - COMMENT_CLOSED => array( - '#description' => t('Users cannot post comments, but existing comments will be displayed.'), - ), - COMMENT_HIDDEN => array( - '#description' => t('Comments are hidden from view.'), - ), - ); - // If the node doesn't have any comments, the "hidden" option makes no - // sense, so don't even bother presenting it to the user. - if (empty($comment_count)) { - $element['comment'][COMMENT_HIDDEN]['#access'] = FALSE; - // Also adjust the description of the "closed" option. - $element['comment'][COMMENT_CLOSED]['#description'] = t('Users cannot post comments.'); - } - return array($element); -} - -/** - * Implements hook_field_formatter_view(). - */ -function comment_field_formatter_view(EntityInterface $entity, $field, $instance, $langcode, $items, $display) { - $element = array(); - - switch ($display['type']) { - case 'comment_default': - // We only ever have one value. - $values = reset($items); - if ($values['comment'] != COMMENT_HIDDEN) { - $additions = FALSE; - if ($values['comment'] && empty($entity->in_preview)) { - // Only attempt to render comments if the node has visible comments. - // Unpublished comments are not included in - // $node->entity_statistics[$field_name]->comment_count, so show - // comments unconditionally if the user is an administrator. - $comment_settings = $instance['settings']['comment']; - if (((!empty($entity->comment_statistics[$field['field_name']]->comment_count) && user_access('access comments')) || user_access('administer comments')) && - !empty($entity->content['#view_mode']) && - !in_array($entity->content['#view_mode'], array('search_result', 'search_index'))) { - // Comment threads aren't added to search results/indexes using the - // formatter, @see comment_node_update_index(). - $mode = $comment_settings['comment_default_mode']; - $comments_per_page = $comment_settings['comment_default_per_page']; - if ($cids = comment_get_thread($entity, $field['field_name'], $mode, $comments_per_page)) { - $comments = comment_load_multiple($cids); - comment_prepare_thread($comments); - $build = comment_view_multiple($comments); - $build['pager']['#theme'] = 'pager'; - $additions['comments'] = $build; - } - } - - // Append comment form if needed. - if ($values['comment'] == COMMENT_OPEN && $comment_settings['comment_form_location'] == COMMENT_FORM_BELOW) { - // Only show the add comment form if the user has permission and the - // view mode is not search_result or search_index. - if (user_access('post comments') && !empty($entity->content['#view_mode']) && - !in_array($entity->content['#view_mode'], array('search_result', 'search_index'))) { - $additions['comment_form'] = comment_add($entity, $field['field_name']); - } - } - if ($additions) { - $additions += array( - '#theme' => 'comment_wrapper__' . $entity->entityType() . '__' . $entity->bundle() . '__' . $field['field_name'], - '#entity' => $entity, - '#display_mode' => $instance['settings']['comment']['comment_default_mode'], - 'comments' => array(), - 'comment_form' => array(), - ); - } - if (!empty($additions)) { - $element[] = $additions; - } - } - } - break; - - } - - return $element; -} - -/** * Implements hook_field_is_empty(). */ function comment_field_is_empty($item, $field) { diff --git a/core/modules/comment/comment.install b/core/modules/comment/comment.install index 79e107b..c6f5f0a 100644 --- a/core/modules/comment/comment.install +++ b/core/modules/comment/comment.install @@ -211,14 +211,14 @@ function comment_schema() { 'status', 'created', 'cid', - 'thread' + 'thread', ), 'comment_uid' => array('uid'), 'comment_entity_langcode' => array( 'entity_id', 'entity_type', 'field_name', - 'langcode' + 'langcode', ), 'comment_created' => array('created'), ), @@ -288,12 +288,12 @@ function comment_schema() { 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, - 'description' => 'The total number of comments on this node.', + 'description' => 'The total number of comments on this entity.', ), ), 'primary key' => array('entity_id', 'entity_type', 'field_name'), 'indexes' => array( - 'node_comment_timestamp' => array('last_comment_timestamp'), + 'last_comment_timestamp' => array('last_comment_timestamp'), 'comment_count' => array('comment_count'), 'last_comment_uid' => array('last_comment_uid'), ), @@ -314,17 +314,14 @@ function comment_schema() { * Implements hook_field_schema(). */ function comment_field_schema($field) { - $columns = array(); - if ($field['type'] == 'comment') { - $columns += array( - 'comment' => array( - 'description' => 'Whether comments are allowed on this entity: 0 = no, 1 = closed (read only), 2 = open (read/write).', - 'type' => 'int', - 'not null' => TRUE, - 'default' => 0, - ), - ); - } + $columns = array( + 'comment' => array( + 'description' => 'Whether comments are allowed on this entity: 0 = no, 1 = closed (read only), 2 = open (read/write).', + 'type' => 'int', + 'not null' => TRUE, + 'default' => 0, + ), + ); return array( 'columns' => $columns, ); @@ -453,9 +450,13 @@ function comment_update_8004() { */ function comment_update_8005(&$sandbox) { // Remove the comment_node foreign key. - db_drop_index('comment', 'comment_node'); + if (db_index_exists('comment', 'comment_node')) { + db_drop_index('comment', 'comment_node'); + } // Remove the comment_nid_langcode index. db_drop_index('comment', 'comment_nid_langcode'); + // Remove comment_num_new index to create new latter here. + db_drop_index('comment', 'comment_num_new'); // Add the entity_type and field_name columns to comment. db_add_field('comment', 'entity_type', array( 'type' => 'varchar', @@ -478,14 +479,31 @@ function comment_update_8005(&$sandbox) { 'default' => 0, 'description' => 'The entity_id to which this comment is a reply.', )); + db_add_index('comment', 'comment_num_new', array( + 'entity_id', + 'entity_type', + 'field_name', + 'status', + 'created', + 'cid', + 'thread' + )); // Add the comment_entity_langcode index. db_add_index('comment', 'comment_entity_langcode', array( 'entity_id', 'entity_type', 'field_name', - 'langcode' + 'langcode', )); + // Rename node_comment_statistics to comment_entity_statistics. + // Remove the statistics_node foreign key. + if (db_index_exists('node_comment_statistics', 'statistics_node')) { + db_drop_index('node_comment_statistics', 'statistics_node'); + } // We need to drop all indexes to make sure their constrains named properly. + db_drop_primary_key('node_comment_statistics'); + db_drop_index('node_comment_statistics', 'node_comment_timestamp'); + db_rename_table('node_comment_statistics', 'comment_entity_statistics'); // Remove the statistics_node foreign key from entity_comment_statistics. // Add the entity_type and field_name columns to comment_entity_statistics. @@ -510,6 +528,9 @@ function comment_update_8005(&$sandbox) { 'default' => 0, 'description' => 'The entity_id to which this comment is a reply.', )); + // Add indexes. + db_add_index('comment_entity_statistics', 'last_comment_timestamp', array('last_comment_timestamp')); + db_add_primary_key('comment_entity_statistics', array('entity_id', 'entity_type', 'field_name')); $t = get_t(); return $t('Updated database to reflect new comment structure'); } @@ -524,7 +545,7 @@ function comment_update_8006(&$sandbox) { // Add a default comment field for existing node comments. $field = array( 'cardinality' => '1', - // We need one per node type to match the existing bundles. + // We need one per content type to match the existing bundles. 'field_name' => 'comment_node_' . $node_type, 'module' => 'comment', 'settings' => array(), @@ -538,54 +559,33 @@ function comment_update_8006(&$sandbox) { } // Add the comment field, setting the instance settings to match those for the // give node_type. + $default_value = variable_get('comment_' . $node_type, 0); + $instance_settings = array( + 'anonymous' => variable_get('comment_anonymous_' . $node_type, 0), + 'subject_field' => variable_get('comment_subject_field_' . $node_type, 1), + 'form_location' => variable_get('comment_subject_field_' . $node_type, 1), + ); + // @todo Find a way to save formatter settings here. + $formatter_settings = array( + 'default_mode' => variable_get('comment_default_mode_' . $node_type, 1), + 'per_page' => variable_get('comment_default_per_page_' . $node_type, 50), + 'preview' => variable_get('comment_preview_' . $node_type, 1), + ); $instance = array( 'bundle' => $node_type, 'default_value' => array( 0 => array( - 'comment' => variable_get('comment_' . $node_type, 0), + 'comment' => $default_value, ) ), 'deleted' => '0', 'description' => '', - 'display' => array( - 'default' => array( - 'label' => 'above', - 'module' => 'comment', - 'settings' => array(), - 'type' => 'comment_default', - 'weight' => '1', - ), - 'rss' => array( - 'type' => 'hidden', - 'label' => 'hidden', - ), - 'teaser' => array( - 'type' => 'hidden', - 'label' => 'hidden', - ), - 'search_index' => array( - 'type' => 'hidden', - 'label' => 'hidden', - ), - 'search_result' => array( - 'type' => 'hidden', - 'label' => 'hidden', - ), - ), 'entity_type' => 'node', 'field_name' => 'comment_node_' . $node_type, 'label' => 'Comment settings', 'required' => 1, 'settings' => array( - 'comment' => array( - 'comment' => variable_get('comment_' . $node_type, 0), - 'comment_default_mode' => variable_get('comment_default_mode_' . $node_type, 1), - 'comment_default_per_page' => variable_get('comment_default_per_page_' . $node_type, 50), - 'comment_anonymous' => variable_get('comment_anonymous_' . $node_type, 0), - 'comment_subject_field' => variable_get('comment_subject_field_' . $node_type, 1), - 'comment_form_location' => variable_get('comment_form_location_' . $node_type, 1), - 'comment_preview' => variable_get('comment_preview_' . $node_type, 1) - ) + 'comment' => $instance_settings, ), 'widget' => array( 'active' => 0, @@ -644,8 +644,8 @@ function comment_update_8007(&$sandbox) { ->fetchAllAssoc('nid'); if (count($nodes) > 0) { - $insert = db_insert('field_data_comment_node_' . $sandbox['node_type'])-> - fields(array( + $insert = db_insert('field_data_comment_node_' . $sandbox['node_type']) + ->fields(array( 'entity_type', 'bundle', 'entity_id', @@ -654,8 +654,8 @@ function comment_update_8007(&$sandbox) { 'delta', 'comment_node_' . $sandbox['node_type'] . '_comment', )); - $revision = db_insert('field_revision_comment_node_' . $sandbox['node_type'])-> - fields(array( + $revision = db_insert('field_revision_comment_node_' . $sandbox['node_type']) + ->fields(array( 'entity_type', 'bundle', 'entity_id', @@ -666,10 +666,12 @@ function comment_update_8007(&$sandbox) { )); // Update the field name to match the node type. - db_update('comment')->fields( - array('field_name' => 'comment_node_' . $sandbox['node_type']) - )->condition('entity_id', array_keys($nodes)) - ->execute(); + db_update('comment') + ->fields(array( + 'field_name' => 'comment_node_' . $sandbox['node_type'], + )) + ->condition('entity_id', array_keys($nodes)) + ->execute(); foreach ($nodes as $nid => $node) { $insert->values(array( 'entity_type' => 'node', @@ -719,7 +721,6 @@ function comment_update_8008(&$sandbox) { return $t('Removed old fields.'); } - /** * @} End of "addtogroup updates-7.x-to-8.x". * The next series of updates should start at 9000. diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index b624f5f..8ce9ba8 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -127,6 +127,11 @@ function comment_help($path, $arg) { * Implements hook_entity_view(). */ function comment_entity_view(EntityInterface $entity, EntityDisplay $display, $view_mode, $langcode) { + // Provide BC for nodes. + // @todo Convert node links to formatter. + if ($entity->entityType() != 'node') { + return; + } $fields = field_info_instances($entity->entityType(), $entity->bundle()); foreach ($fields as $field_name => $instance) { $links = array(); @@ -179,7 +184,6 @@ function comment_entity_view(EntityInterface $entity, EntityDisplay $display, $v $values = field_get_items($entity, $field_name); $value = reset($values); if (!empty($value['comment']) && $value['comment'] == COMMENT_OPEN) { - $comment_form_location = $instance['settings']['comment']['comment_form_location']; if (user_access('post comments')) { $links['comment-add'] = array( 'title' => t('Add new comment'), @@ -187,6 +191,7 @@ function comment_entity_view(EntityInterface $entity, EntityDisplay $display, $v 'attributes' => array('title' => t('Add a new comment to this page.')), 'fragment' => 'comment-form', ); + $comment_form_location = $instance['settings']['comment']['form_location']; if ($comment_form_location == COMMENT_FORM_SEPARATE_PAGE) { $links['comment-add']['href'] = 'comment/reply/'. $entity->entityType() . '/' . $entity->id() .'/' . $field_name; } @@ -207,10 +212,11 @@ function comment_entity_view(EntityInterface $entity, EntityDisplay $display, $v $values = field_get_items($entity, $field_name); if (is_array($values) && ($value = reset($values)) && !empty($value['comment']) && $value['comment'] == COMMENT_OPEN) { - $comment_form_location = $instance['settings']['comment']['comment_form_location']; + if (user_access('post comments')) { // Show the "post comment" link if the form is on another page, or // if there are existing comments that the link will skip past. + $comment_form_location = $instance['settings']['comment']['form_location']; if ($comment_form_location == COMMENT_FORM_SEPARATE_PAGE || (!empty($entity->comment_statistics[$field_name]->comment_count) && user_access('access comments'))) { $links['comment-add'] = array( 'title' => t('Add new comment'), @@ -262,7 +268,7 @@ function comment_entity_bundle_info() { 'admin' => array( 'path' => 'admin/structure/comments/%comment_field_name', 'bundle argument' => 3, - 'real path' => 'admin/structure/comments/' . strtr($field_name, '_', '-'), + 'real path' => 'admin/structure/comments/' . $field_name, ), ); } @@ -279,9 +285,8 @@ function comment_entity_bundle_info() { * The actual field name with hyphens returned to underscores. */ function comment_field_name_load($arg) { - $field_name = strtr($arg, array('-' => '_')); - if (($field = field_info_field($field_name)) && $field['type'] == 'comment') { - return $field_name; + if (($field = field_info_field($arg)) && $field['type'] == 'comment') { + return $field; } return FALSE; @@ -2101,10 +2106,10 @@ function comment_library_info() { * @see field_info_fields(). */ function comment_get_comment_fields($entity_type = NULL) { - return array_filter(field_info_fields(), function ($value) use($entity_type) { + return array_filter(field_info_field_map(), function ($value) use($entity_type) { if ($value['type'] == 'comment') { if (isset($entity_type)) { - return in_array($entity_type, array_keys($value['bundles'])); + return isset($value['bundles'][$entity_type]); } return TRUE; } diff --git a/core/modules/comment/lib/Drupal/comment/CommentFormController.php b/core/modules/comment/lib/Drupal/comment/CommentFormController.php index ff7d2d3..118eb39 100644 --- a/core/modules/comment/lib/Drupal/comment/CommentFormController.php +++ b/core/modules/comment/lib/Drupal/comment/CommentFormController.php @@ -2,7 +2,7 @@ /** * @file - * Definition of Drupal\comment\CommentFormController. + * Contains Drupal\comment\CommentFormController. */ namespace Drupal\comment; @@ -17,7 +17,7 @@ class CommentFormController extends EntityFormControllerNG { /** - * Overrides Drupal\Core\Entity\EntityFormControllerNG::form(). + * Overrides EntityFormControllerNG::form(). */ public function form(array $form, array &$form_state, EntityInterface $comment) { global $user; diff --git a/core/modules/comment/lib/Drupal/comment/CommentStorageController.php b/core/modules/comment/lib/Drupal/comment/CommentStorageController.php index 03db901..12cd63d 100644 --- a/core/modules/comment/lib/Drupal/comment/CommentStorageController.php +++ b/core/modules/comment/lib/Drupal/comment/CommentStorageController.php @@ -363,7 +363,7 @@ public function baseFieldDefinitions() { 'description' => t("The comment 'new' marker for the current user (0 read, 1 new, 2 updated)."), 'type' => 'integer_field', 'computed' => TRUE, - 'class' => '\Drupal\comment\FieldNewItem', + 'class' => '\Drupal\comment\Type\CommentNewItem', ); return $properties; } diff --git a/core/modules/comment/lib/Drupal/comment/FieldNewItem.php b/core/modules/comment/lib/Drupal/comment/FieldNewItem.php deleted file mode 100644 index 7ef4092..0000000 --- a/core/modules/comment/lib/Drupal/comment/FieldNewItem.php +++ /dev/null @@ -1,40 +0,0 @@ - 'integer', - 'label' => t('Integer value'), - 'class' => '\Drupal\comment\FieldNewValue', - ); - } - return static::$propertyDefinitions; - } -}