function CommentLazyBuilders::renderForm

Same name in other branches
  1. 9 core/modules/comment/src/CommentLazyBuilders.php \Drupal\comment\CommentLazyBuilders::renderForm()
  2. 10 core/modules/comment/src/CommentLazyBuilders.php \Drupal\comment\CommentLazyBuilders::renderForm()
  3. 11.x core/modules/comment/src/CommentLazyBuilders.php \Drupal\comment\CommentLazyBuilders::renderForm()

#lazy_builder callback; builds the comment form.

Parameters

string $commented_entity_type_id: The commented entity type ID.

string $commented_entity_id: The commented entity ID.

string $field_name: The comment field name.

string $comment_type_id: The comment type ID.

Return value

array A renderable array containing the comment form.

File

core/modules/comment/src/CommentLazyBuilders.php, line 110

Class

CommentLazyBuilders
Defines a service for comment #lazy_builder callbacks.

Namespace

Drupal\comment

Code

public function renderForm($commented_entity_type_id, $commented_entity_id, $field_name, $comment_type_id) {
    $values = [
        'entity_type' => $commented_entity_type_id,
        'entity_id' => $commented_entity_id,
        'field_name' => $field_name,
        'comment_type' => $comment_type_id,
        'pid' => NULL,
    ];
    $comment = $this->entityTypeManager
        ->getStorage('comment')
        ->create($values);
    return $this->entityFormBuilder
        ->getForm($comment);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.