public function MediaController::loadMedia in Gutenberg 8.2
Same name and namespace in other branches
- 8 src/Controller/MediaController.php \Drupal\gutenberg\Controller\MediaController::loadMedia()
Load media data.
Parameters
\Symfony\Component\HttpFoundation\Request $request: Current request.
string $media: Media data (numeric or stringified JSON for media data processing).
Return value
\Symfony\Component\HttpFoundation\JsonResponse The JSON response.
Throws
\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
\Drupal\Component\Plugin\Exception\PluginNotFoundException
1 string reference to 'MediaController::loadMedia'
File
- src/
Controller/ MediaController.php, line 117
Class
- MediaController
- Returns responses for our image routes.
Namespace
Drupal\gutenberg\ControllerCode
public function loadMedia(Request $request, string $media) {
$media_entities = $this->mediaSelectionProcessorManager
->processData($media);
try {
if (!$media_entities) {
throw new MediaEntityNotFoundException();
}
return new JsonResponse($this->mediaService
->loadMediaData(reset($media_entities)));
} catch (MediaEntityNotFoundException $exception) {
throw new NotFoundHttpException($exception
->getMessage(), $exception);
}
}