You are here

public function MediaFileUpload::submit in Panopoly 8.2

File

modules/panopoly/panopoly_media/src/Plugin/EntityBrowser/Widget/MediaFileUpload.php, line 78

Class

MediaFileUpload
Uses upload to create media images.

Namespace

Drupal\panopoly_media\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);
  }
}