protected function AddMediaFormBase::createFileItem in Media Directories 8
Same name and namespace in other branches
- 2.x modules/media_directories_ui/src/Form/AddMediaFormBase.php \Drupal\media_directories_ui\Form\AddMediaFormBase::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.
File
- modules/
media_directories_ui/ src/ Form/ AddMediaFormBase.php, line 624
Class
- AddMediaFormBase
- Class AddMediaFormBase.
Namespace
Drupal\media_directories_ui\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);
}