diff --git a/core/modules/comment/src/CommentPostRenderCache.php b/core/modules/comment/src/CommentPostRenderCache.php index fd6fbc73eb4e60aa72564ecb976804b730564e31..960c06fcadb2b7a0b948543060a73e24a70aec24 100644 --- a/core/modules/comment/src/CommentPostRenderCache.php +++ b/core/modules/comment/src/CommentPostRenderCache.php @@ -15,7 +15,6 @@ use Drupal\Core\Session\AccountInterface; use Drupal\Core\Url; use Drupal\Core\Render\Renderer; -use Drupal\field\Entity\FieldStorageConfig; /** * Defines a service for comment post render cache callbacks. @@ -99,19 +98,17 @@ public function __construct(EntityManagerInterface $entity_manager, EntityFormBu * - entity_type: an entity type * - entity_id: an entity ID * - field_name: a comment field name + * - comment_type: the comment type * * @return array * A renderable array containing the comment form. */ public function renderForm(array $element, array $context) { - $field_name = $context['field_name']; - $entity = $this->entityManager->getStorage($context['entity_type'])->load($context['entity_id']); - $field_storage = FieldStorageConfig::loadByName($entity->getEntityTypeId(), $field_name); $values = array( - 'entity_type' => $entity->getEntityTypeId(), - 'entity_id' => $entity->id(), - 'field_name' => $field_name, - 'comment_type' => $field_storage->getSetting('bundle'), + 'entity_type' => $context['entity_type'], + 'entity_id' => $context['entity_id'], + 'field_name' => $context['field_name'], + 'comment_type' => $context['comment_type'], 'pid' => NULL, ); $comment = $this->entityManager->getStorage('comment')->create($values); diff --git a/core/modules/comment/src/Plugin/Field/FieldFormatter/CommentDefaultFormatter.php b/core/modules/comment/src/Plugin/Field/FieldFormatter/CommentDefaultFormatter.php index 52b665860b861447328dbb11db557d0200eaf7b3..1bb8134c4162f7c1e2c98692df33dee327c062c7 100644 --- a/core/modules/comment/src/Plugin/Field/FieldFormatter/CommentDefaultFormatter.php +++ b/core/modules/comment/src/Plugin/Field/FieldFormatter/CommentDefaultFormatter.php @@ -204,6 +204,7 @@ public function viewElements(FieldItemListInterface $items) { 'entity_type' => $entity->getEntityTypeId(), 'entity_id' => $entity->id(), 'field_name' => $field_name, + 'comment_type' => $this->getFieldSetting('comment_type'), ); $placeholder = drupal_render_cache_generate_placeholder($callback, $context); $output['comment_form'] = array(