You are here

public function Upload::submit in Media entity document 8

File

src/Plugin/EntityBrowser/Widget/Upload.php, line 78

Class

Upload
Uses upload to create media entity documents.

Namespace

Drupal\media_entity_document\Plugin\EntityBrowser\Widget

Code

public function submit(array &$element, array &$form, FormStateInterface $form_state) {
  if (!empty($form_state
    ->getTriggeringElement()['#eb_widget_main_submit'])) {
    $documents = $this
      ->prepareEntities($form, $form_state);
    array_walk($documents, function (MediaInterface $media) {
      $media
        ->save();
    });
    $this
      ->selectEntities($documents, $form_state);
    $this
      ->clearFormValues($element, $form_state);
  }
}