function FileSelection::createNewEntity
Same name in other branches
- 8.9.x core/modules/file/src/Plugin/EntityReferenceSelection/FileSelection.php \Drupal\file\Plugin\EntityReferenceSelection\FileSelection::createNewEntity()
- 10 core/modules/file/src/Plugin/EntityReferenceSelection/FileSelection.php \Drupal\file\Plugin\EntityReferenceSelection\FileSelection::createNewEntity()
- 11.x core/modules/file/src/Plugin/EntityReferenceSelection/FileSelection.php \Drupal\file\Plugin\EntityReferenceSelection\FileSelection::createNewEntity()
Overrides DefaultSelection::createNewEntity
File
-
core/
modules/ file/ src/ Plugin/ EntityReferenceSelection/ FileSelection.php, line 40
Class
- FileSelection
- Provides specific access control for the file entity type.
Namespace
Drupal\file\Plugin\EntityReferenceSelectionCode
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;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.