Browse Source

Coding standards

pull/816/head
dannylamb 4 years ago
parent
commit
9ff811a3b1
  1. 2
      src/Controller/MediaSourceController.php
  2. 5
      src/MediaSource/MediaSourceService.php

2
src/Controller/MediaSourceController.php

@ -249,7 +249,7 @@ class MediaSourceController extends ControllerBase {
try { try {
$this->service->putToMedia( $this->service->putToMedia(
$media, $media,
$destination_field, $destination_field,
$request->getContent(TRUE), $request->getContent(TRUE),
$content_type, $content_type,
$content_location $content_location

5
src/MediaSource/MediaSourceService.php

@ -366,7 +366,7 @@ class MediaSourceService {
// Validate file extension. // Validate file extension.
$bundle = $media->bundle(); $bundle = $media->bundle();
$destination_field_config= $this->entityTypeManager->getStorage('field_config')->load("media.$bundle.$destination_field"); $destination_field_config = $this->entityTypeManager->getStorage('field_config')->load("media.$bundle.$destination_field");
$valid_extensions = $destination_field_config->getSetting('file_extensions'); $valid_extensions = $destination_field_config->getSetting('file_extensions');
$errors = file_validate_extensions($file, $valid_extensions); $errors = file_validate_extensions($file, $valid_extensions);
@ -383,7 +383,7 @@ class MediaSourceService {
$this->updateFile($file, $resource, $mimetype); $this->updateFile($file, $resource, $mimetype);
$file->save(); $file->save();
// Update the media // Update the media.
$media->{$destination_field}->setValue([ $media->{$destination_field}->setValue([
'target_id' => $file->id(), 'target_id' => $file->id(),
]); ]);
@ -393,4 +393,5 @@ class MediaSourceService {
throw new BadRequestHttpException("Media does not have destination field $destination_field"); throw new BadRequestHttpException("Media does not have destination field $destination_field");
} }
} }
} }

Loading…
Cancel
Save