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

Breadcrumb

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

function NodeSelection::createNewEntity

Overrides DefaultSelection::createNewEntity

File

core/modules/node/src/Plugin/EntityReferenceSelection/NodeSelection.php, line 41

Class

NodeSelection
Provides specific access control for the node entity type.

Namespace

Drupal\node\Plugin\EntityReferenceSelection

Code

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

API Navigation

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