public static function Recipe::buildResponse in Recipe 8.2
Builds up a response with the rendered view as content.
Parameters
string $view_id: The view ID.
string $display_id: The display ID.
array $args: (optional) The arguments of the view.
Return value
\Symfony\Component\HttpFoundation\Response The built response.
Overrides ResponseDisplayPluginInterface::buildResponse
File
- src/
Plugin/ views/ display/ Recipe.php, line 99
Class
- Recipe
- The plugin that handles a recipe format, such as RecipeML.
Namespace
Drupal\recipe\Plugin\views\displayCode
public static function buildResponse($view_id, $display_id, array $args = []) {
$build = static::buildBasicRenderable($view_id, $display_id, $args);
// Set up an empty response, so the style plugins can set the proper
// Content-Type header.
$response = new CacheableResponse('', 200);
$build['#response'] = $response;
$output = (string) \Drupal::service('renderer')
->renderRoot($build);
if (empty($output)) {
throw new NotFoundHttpException();
}
$response
->setContent($output);
$cache_metadata = CacheableMetadata::createFromRenderArray($build);
$response
->addCacheableDependency($cache_metadata);
return $response;
}