protected function FileUpload::prepareEntities in Lightning Media 8
Same name and namespace in other branches
- 8.4 src/Plugin/EntityBrowser/Widget/FileUpload.php \Drupal\lightning_media\Plugin\EntityBrowser\Widget\FileUpload::prepareEntities()
- 8.2 src/Plugin/EntityBrowser/Widget/FileUpload.php \Drupal\lightning_media\Plugin\EntityBrowser\Widget\FileUpload::prepareEntities()
- 8.3 src/Plugin/EntityBrowser/Widget/FileUpload.php \Drupal\lightning_media\Plugin\EntityBrowser\Widget\FileUpload::prepareEntities()
Overrides EntityFormProxy::prepareEntities
File
- src/
Plugin/ EntityBrowser/ Widget/ FileUpload.php, line 33
Class
- FileUpload
- An Entity Browser widget for creating media entities from uploaded files.
Namespace
Drupal\lightning_media\Plugin\EntityBrowser\WidgetCode
protected function prepareEntities(array $form, FormStateInterface $form_state) {
$entities = parent::prepareEntities($form, $form_state);
$get_file = function (MediaInterface $entity) {
return MediaHelper::getSourceField($entity)->entity;
};
if ($this->configuration['return_file']) {
return array_map($get_file, $entities);
}
else {
return $entities;
}
}