You are here

protected function MediaBulkUploadForm::copyFormValuesToEntity in Media Bulk Upload 8

Copy the submitted values for the media subform to the media entity.

Parameters

\Drupal\media\MediaInterface $media: Media Entity.

array $extracted: Extracted entity values.

\Drupal\Core\Form\FormStateInterface $form_state: Form State.

1 call to MediaBulkUploadForm::copyFormValuesToEntity()
MediaBulkUploadForm::submitForm in src/Form/MediaBulkUploadForm.php
Submit handler to create the file entities and media entities.

File

src/Form/MediaBulkUploadForm.php, line 491

Class

MediaBulkUploadForm
Class BulkMediaUploadForm.

Namespace

Drupal\media_bulk_upload\Form

Code

protected function copyFormValuesToEntity(MediaInterface $media, array $extracted, FormStateInterface $form_state) {
  foreach ($form_state
    ->getValues() as $name => $values) {
    if (isset($extracted[$name]) || !$media
      ->hasField($name)) {
      continue;
    }
    $media
      ->set($name, $values);
  }
}