You are here

public function Upload::submit in Media entity audio 8.2

Same name and namespace in other branches
  1. 8 src/Plugin/EntityBrowser/Widget/Upload.php \Drupal\media_entity_audio\Plugin\EntityBrowser\Widget\Upload::submit()

File

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

Class

Upload
Uses upload to create media entity audios.

Namespace

Drupal\media_entity_audio\Plugin\EntityBrowser\Widget

Code

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