public function MediaController::load in Gutenberg 8.2
Same name and namespace in other branches
- 8 src/Controller/MediaController.php \Drupal\gutenberg\Controller\MediaController::load()
Get data of the media entity required for Gutenberg editor.
Parameters
\Symfony\Component\HttpFoundation\Request $request: Current request.
\Drupal\file\Entity\File|null $file: Loaded found file entity instance.
Return value
\Symfony\Component\HttpFoundation\JsonResponse The JSON response.
Throws
\Exception
1 string reference to 'MediaController::load'
File
- src/
Controller/ MediaController.php, line 210
Class
- MediaController
- Returns responses for our image routes.
Namespace
Drupal\gutenberg\ControllerCode
public function load(Request $request, File $file = NULL) {
if (!$file) {
throw new NotFoundHttpException('File entity not found.');
}
try {
return new JsonResponse($this->mediaService
->loadFileData($file));
} catch (FileEntityNotFoundException $exception) {
throw new NotFoundHttpException($exception
->getMessage(), $exception);
}
}