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

Breadcrumb

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

function FileSelection::createNewEntity

Overrides DefaultSelection::createNewEntity

File

core/modules/file/src/Plugin/EntityReferenceSelection/FileSelection.php, line 41

Class

FileSelection
Provides specific access control for the file entity type.

Namespace

Drupal\file\Plugin\EntityReferenceSelection

Code

public function createNewEntity($entity_type_id, $bundle, $label, $uid) {
    $file = parent::createNewEntity($entity_type_id, $bundle, $label, $uid);
    // In order to create a referenceable file, it needs to have a "permanent"
    // status.
    
    /** @var \Drupal\file\FileInterface $file */
    $file->setPermanent();
    return $file;
}

API Navigation

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