public function FileUpload::submit in Lightning Media 8.4
Same name and namespace in other branches
- 8 src/Plugin/EntityBrowser/Widget/FileUpload.php \Drupal\lightning_media\Plugin\EntityBrowser\Widget\FileUpload::submit()
- 8.2 src/Plugin/EntityBrowser/Widget/FileUpload.php \Drupal\lightning_media\Plugin\EntityBrowser\Widget\FileUpload::submit()
- 8.3 src/Plugin/EntityBrowser/Widget/FileUpload.php \Drupal\lightning_media\Plugin\EntityBrowser\Widget\FileUpload::submit()
Overrides EntityFormProxy::submit
File
- src/
Plugin/ EntityBrowser/ Widget/ FileUpload.php, line 178
Class
- FileUpload
- An Entity Browser widget for creating media entities from uploaded files.
Namespace
Drupal\lightning_media\Plugin\EntityBrowser\WidgetCode
public function submit(array &$element, array &$form, FormStateInterface $form_state) {
/** @var \Drupal\media\MediaInterface $entity */
$entity = $element['entity']['#entity'];
$file = MediaHelper::useFile($entity, MediaHelper::getSourceField($entity)->entity);
$file
->setPermanent();
$file
->save();
$entity
->save();
$selection = [
$this->configuration['return_file'] ? $file : $entity,
];
$this
->selectEntities($selection, $form_state);
}