You are here

protected function MediaBulkUploadForm::getNewMediaValues in Media Bulk Upload 8

Builds the array of all necessary info for the new media entity.

Parameters

\Drupal\media\MediaTypeInterface $mediaType: Media Type ID.

array $fileInfo: File info.

\Drupal\file\FileInterface $file: File entity.

Return value

array Return an array describing the new media entity.

1 call to MediaBulkUploadForm::getNewMediaValues()
MediaBulkUploadForm::processFile in src/Form/MediaBulkUploadForm.php
Process a file upload.

File

src/Form/MediaBulkUploadForm.php, line 468

Class

MediaBulkUploadForm
Class BulkMediaUploadForm.

Namespace

Drupal\media_bulk_upload\Form

Code

protected function getNewMediaValues(MediaTypeInterface $mediaType, array $fileInfo, FileInterface $file) {
  $targetFieldName = $this->mediaSubFormManager
    ->getMediaTypeManager()
    ->getTargetFieldName($mediaType);
  return [
    'bundle' => $mediaType
      ->id(),
    'name' => $fileInfo['filename'],
    $targetFieldName => [
      'target_id' => $file
        ->id(),
      'title' => $fileInfo['filename'],
    ],
  ];
}