You are here

public function Upload::submit in Media entity video 8

Same name and namespace in other branches
  1. 8.3 src/Plugin/EntityBrowser/Widget/Upload.php \Drupal\media_entity_video\Plugin\EntityBrowser\Widget\Upload::submit()
  2. 8.2 src/Plugin/EntityBrowser/Widget/Upload.php \Drupal\media_entity_video\Plugin\EntityBrowser\Widget\Upload::submit()

File

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

Class

Upload
Uses upload to create media entity videos.

Namespace

Drupal\media_entity_video\Plugin\EntityBrowser\Widget

Code

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