You are here

protected function FileUpload::prepareEntities in Lightning Media 8.3

Same name and namespace in other branches
  1. 8.4 src/Plugin/EntityBrowser/Widget/FileUpload.php \Drupal\lightning_media\Plugin\EntityBrowser\Widget\FileUpload::prepareEntities()
  2. 8 src/Plugin/EntityBrowser/Widget/FileUpload.php \Drupal\lightning_media\Plugin\EntityBrowser\Widget\FileUpload::prepareEntities()
  3. 8.2 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 35

Class

FileUpload
An Entity Browser widget for creating media entities from uploaded files.

Namespace

Drupal\lightning_media\Plugin\EntityBrowser\Widget

Code

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;
  }
}