diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module
index 1ab6691..4353d89 100644
--- a/core/modules/comment/comment.module
+++ b/core/modules/comment/comment.module
@@ -518,33 +518,6 @@ function comment_node_view_alter(array &$build, EntityInterface $node, EntityVie
 }
 
 /**
- * Returns a rendered form to comment the given entity.
- *
- * @param \Drupal\Core\Entity\EntityInterface $entity
- *   The entity to which the comments are in reply to.
- * @param string $field_name
- *   The field name where the comments were entered.
- * @param int $pid
- *   (optional) Some comments are replies to other comments. In those cases,
- *   $pid is the parent comment's comment ID. Defaults to NULL.
- *
- * @return array
- *   The renderable array for the comment addition form.
- */
-function comment_add(EntityInterface $entity, $field_name = 'comment', $pid = NULL) {
-  $field = Fieldconfig::loadByName($entity->getEntityTypeId(), $field_name);
-  $values = array(
-    'entity_type' => $entity->getEntityTypeId(),
-    'entity_id' => $entity->id(),
-    'field_name' => $field_name,
-    'comment_type' => $field->getSetting('bundle'),
-    'pid' => $pid,
-  );
-  $comment = entity_create('comment', $values);
-  return \Drupal::service('entity.form_builder')->getForm($comment);
-}
-
-/**
  * Retrieves comments for a thread.
  *
  * @param \Drupal\Core\Entity\EntityInterface $entity
diff --git a/core/modules/comment/src/Plugin/Field/FieldFormatter/CommentDefaultFormatter.php b/core/modules/comment/src/Plugin/Field/FieldFormatter/CommentDefaultFormatter.php
index 77681c9..1792762 100644
--- a/core/modules/comment/src/Plugin/Field/FieldFormatter/CommentDefaultFormatter.php
+++ b/core/modules/comment/src/Plugin/Field/FieldFormatter/CommentDefaultFormatter.php
@@ -10,11 +10,13 @@
 use Drupal\comment\CommentStorageInterface;
 use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
 use Drupal\Core\Entity\EntityViewBuilderInterface;
+use Drupal\Core\Entity\EntityFormBuilderInterface;
 use Drupal\Core\Field\FieldItemListInterface;
 use Drupal\Core\Session\AccountInterface;
 use Drupal\Core\Field\FieldDefinitionInterface;
 use Drupal\Core\Field\FormatterBase;
 use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
+use Drupal\field\Entity\FieldConfig;
 use Symfony\Component\DependencyInjection\ContainerInterface;
 
 /**
@@ -65,6 +67,13 @@ public static function defaultSettings() {
   protected $viewBuilder;
 
   /**
+   * The comment render controller.
+   *
+   * @var \Drupal\Core\Entity\EntityFormBuilderInterface
+   */
+  protected $formBuilder;
+
+  /**
    * {@inheritdoc}
    */
   public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
@@ -78,7 +87,8 @@ public static function create(ContainerInterface $container, array $configuratio
       $configuration['third_party_settings'],
       $container->get('current_user'),
       $container->get('entity.manager')->getStorage('comment'),
-      $container->get('entity.manager')->getViewBuilder('comment')
+      $container->get('entity.manager')->getViewBuilder('comment'),
+      $container->get('entity.form_builder')
     );
   }
 
@@ -105,12 +115,15 @@ public static function create(ContainerInterface $container, array $configuratio
    *   The comment storage.
    * @param \Drupal\Core\Entity\EntityViewBuilderInterface $comment_view_builder
    *   The comment view builder.
+   * @param \Drupal\Core\Entity\EntityFormBuilderInterface $form_builder
+   *   The entity form builder.
    */
-  public function __construct($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, $label, $view_mode, array $third_party_settings, AccountInterface $current_user, CommentStorageInterface $comment_storage, EntityViewBuilderInterface $comment_view_builder) {
+  public function __construct($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, $label, $view_mode, array $third_party_settings, AccountInterface $current_user, CommentStorageInterface $comment_storage, EntityViewBuilderInterface $comment_view_builder, EntityFormBuilderInterface $form_builder) {
     parent::__construct($plugin_id, $plugin_definition, $field_definition, $settings, $label, $view_mode, $third_party_settings);
     $this->viewBuilder = $comment_view_builder;
     $this->storage = $comment_storage;
     $this->currentUser = $current_user;
+    $this->formBuilder = $form_builder;
   }
 
   /**
@@ -174,7 +187,17 @@ public function viewElements(FieldItemListInterface $items) {
           // All users in the "anonymous" role can use the same form: it is fine
           // for this form to be stored in the render cache.
           if ($this->currentUser->isAnonymous()) {
-            $output['comment_form'] = comment_add($entity, $field_name);
+            $entity_type = $entity->getEntityTypeId();
+            $field = Fieldconfig::loadByName($entity_type, $field_name);
+            $values = array(
+              'entity_type' => $entity_type,
+              'entity_id' => $entity->id(),
+              'field_name' => $field_name,
+              'comment_type' => $field->getSetting('bundle'),
+              'pid' => NULL,
+            );
+            $comment = $this->storage->create($values);
+            $output['comment_form'] = $this->entityFormBuilder->getForm($comment);
           }
           // All other users need a user-specific form, which would break the
           // render cache: hence use a #post_render_cache callback.
