You are here

public function Upload::submit in Media entity image 8

File

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

Class

Upload
Uses upload to create media entity images.

Namespace

Drupal\media_entity_image\Plugin\EntityBrowser\Widget

Code

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