protected function FileUploadForm::prepareMediaEntityForSave in Drupal 8
Same name and namespace in other branches
- 9 core/modules/media_library/src/Form/FileUploadForm.php \Drupal\media_library\Form\FileUploadForm::prepareMediaEntityForSave()
Prepares a created media item to be permanently saved.
Parameters
\Drupal\media\MediaInterface $media: The unsaved media item.
Overrides AddFormBase::prepareMediaEntityForSave
File
- core/
modules/ media_library/ src/ Form/ FileUploadForm.php, line 348
Class
- FileUploadForm
- Creates a form to create media entities from uploaded files.
Namespace
Drupal\media_library\FormCode
protected function prepareMediaEntityForSave(MediaInterface $media) {
/** @var \Drupal\file\FileInterface $file */
$file = $media
->get($this
->getSourceFieldName($media->bundle->entity))->entity;
$file
->setPermanent();
$file
->save();
}