You are here

public function MediaEntityDropzoneJsEbWidget::prepareEntities in DropzoneJS 8

Same name and namespace in other branches
  1. 8.2 modules/eb_widget/src/Plugin/EntityBrowser/Widget/MediaEntityDropzoneJsEbWidget.php \Drupal\dropzonejs_eb_widget\Plugin\EntityBrowser\Widget\MediaEntityDropzoneJsEbWidget::prepareEntities()

Overrides DropzoneJsEbWidget::prepareEntities

2 calls to MediaEntityDropzoneJsEbWidget::prepareEntities()
InlineEntityFormMediaWidget::submitEdit in modules/eb_widget/src/Plugin/EntityBrowser/Widget/InlineEntityFormMediaWidget.php
Submit callback for the edit button.
MediaEntityDropzoneJsEbWidget::submit in modules/eb_widget/src/Plugin/EntityBrowser/Widget/MediaEntityDropzoneJsEbWidget.php

File

modules/eb_widget/src/Plugin/EntityBrowser/Widget/MediaEntityDropzoneJsEbWidget.php, line 160

Class

MediaEntityDropzoneJsEbWidget
Provides an Entity Browser widget that uploads uploads media entities.

Namespace

Drupal\dropzonejs_eb_widget\Plugin\EntityBrowser\Widget

Code

public function prepareEntities(array $form, FormStateInterface $form_state) {
  $entities = [];
  $bundle = $this
    ->getBundle();
  foreach (parent::prepareEntities($form, $form_state) as $file) {
    $entities[] = $this->entityTypeManager
      ->getStorage('media')
      ->create([
      'bundle' => $bundle
        ->id(),
      $bundle
        ->getTypeConfiguration()['source_field'] => $file,
      'uid' => $this->currentUser
        ->id(),
      'status' => TRUE,
      'type' => $bundle
        ->getType()
        ->getPluginId(),
    ]);
  }
  return $entities;
}