You are here

public function TestMediaFilterController::preview in Drupal 10

Same name and namespace in other branches
  1. 9 core/modules/media/tests/modules/media_test_embed/src/Controller/TestMediaFilterController.php \Drupal\media_test_embed\Controller\TestMediaFilterController::preview()

Returns a HTML response containing a preview of the text after filtering.

Applies all of the given text format's filters, not just the `media_embed` filter, because for example `filter_align` and `filter_caption` may apply to it as well.

Parameters

\Symfony\Component\HttpFoundation\Request $request: The request object.

\Drupal\filter\FilterFormatInterface $filter_format: The text format.

Return value

\Symfony\Component\HttpFoundation\Response The filtered text.

Throws

\Symfony\Component\HttpKernel\Exception\NotFoundHttpException Throws an exception if 'text' parameter is not found in the query string.

Overrides MediaFilterController::preview

See also

\Drupal\editor\EditorController::getUntransformedText

File

core/modules/media/tests/modules/media_test_embed/src/Controller/TestMediaFilterController.php, line 18

Class

TestMediaFilterController
Controller to allow testing of error handling of Media Embed in text editors.

Namespace

Drupal\media_test_embed\Controller

Code

public function preview(Request $request, FilterFormatInterface $filter_format) {
  if (\Drupal::state()
    ->get('test_media_filter_controller_throw_error', FALSE)) {
    throw new NotFoundHttpException();
  }
  return parent::preview($request, $filter_format);
}