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

Breadcrumb

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

function TermSelection::createNewEntity

Overrides DefaultSelection::createNewEntity

File

core/modules/taxonomy/src/Plugin/EntityReferenceSelection/TermSelection.php, line 117

Class

TermSelection
Provides specific access control for the taxonomy_term entity type.

Namespace

Drupal\taxonomy\Plugin\EntityReferenceSelection

Code

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

API Navigation

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