protected function FileUploadForm::createFileItem in Drupal 9
Same name and namespace in other branches
- 8 core/modules/media_library/src/Form/FileUploadForm.php \Drupal\media_library\Form\FileUploadForm::createFileItem()
Create a file field item.
Parameters
\Drupal\media\MediaTypeInterface $media_type: The media type of the media item.
Return value
\Drupal\file\Plugin\Field\FieldType\FileItem A created file item.
2 calls to FileUploadForm::createFileItem()
- FileUploadForm::buildInputElement in core/
modules/ media_library/ src/ Form/ FileUploadForm.php - Builds the element for submitting source field value(s).
- FileUploadForm::createMediaFromValue in core/
modules/ media_library/ src/ Form/ FileUploadForm.php - Creates a new, unsaved media item from a source field value.
File
- core/
modules/ media_library/ src/ Form/ FileUploadForm.php, line 335
Class
- FileUploadForm
- Creates a form to create media entities from uploaded files.
Namespace
Drupal\media_library\FormCode
protected function createFileItem(MediaTypeInterface $media_type) {
$field_definition = $media_type
->getSource()
->getSourceFieldDefinition($media_type);
$data_definition = FieldItemDataDefinition::create($field_definition);
return new FileItem($data_definition);
}