You are here

public function MediaController::dialog in Gutenberg 8

Same name and namespace in other branches
  1. 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'
gutenberg.routing.yml in ./gutenberg.routing.yml
gutenberg.routing.yml

File

src/Controller/MediaController.php, line 71

Class

MediaController
Returns responses for our image routes.

Namespace

Drupal\gutenberg\Controller

Code

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);
  }
}