Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. CommentSelection.php

function CommentSelection::createNewEntity

Overrides DefaultSelection::createNewEntity

File

core/modules/comment/src/Plugin/EntityReferenceSelection/CommentSelection.php, line 42

Class

CommentSelection
Provides specific access control for the comment entity type.

Namespace

Drupal\comment\Plugin\EntityReferenceSelection

Code

public function createNewEntity($entity_type_id, $bundle, $label, $uid) {
    $comment = parent::createNewEntity($entity_type_id, $bundle, $label, $uid);
    // In order to create a referenceable comment, it needs to published.
    
    /** @var \Drupal\comment\CommentInterface $comment */
    $comment->setPublished();
    return $comment;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal