public function MediaController::dialog in Gutenberg 8
Same name and namespace in other branches
- 8.2 src/Controller/MediaController.php \Drupal\gutenberg\Controller\MediaController::dialog()
Render Drupal's media library dialog.
Parameters
\Symfony\Component\HttpFoundation\Request $request: Current request.
Return value
\Symfony\Component\HttpFoundation\JsonResponse The JSON response.
Throws
\Exception
1 string reference to 'MediaController::dialog'
File
- src/
Controller/ MediaController.php, line 71
Class
- MediaController
- Returns responses for our image routes.
Namespace
Drupal\gutenberg\ControllerCode
public function dialog(Request $request) {
try {
return new JsonResponse([
'html' => $this->mediaService
->renderDialog(explode(',', $request
->get('types', []))),
]);
} catch (MediaTypeNotFoundException $exception) {
return new JsonResponse([
'error' => $this
->t($exception
->getMessage()),
], 404);
}
}