function Feed::buildResponse
Same name in other branches
- 9 core/modules/views/src/Plugin/views/display/Feed.php \Drupal\views\Plugin\views\display\Feed::buildResponse()
- 8.9.x core/modules/views/src/Plugin/views/display/Feed.php \Drupal\views\Plugin\views\display\Feed::buildResponse()
- 11.x core/modules/views/src/Plugin/views/display/Feed.php \Drupal\views\Plugin\views\display\Feed::buildResponse()
Overrides ResponseDisplayPluginInterface::buildResponse
File
-
core/
modules/ views/ src/ Plugin/ views/ display/ Feed.php, line 99
Class
- Feed
- The plugin that handles a feed, such as RSS or atom.
Namespace
Drupal\views\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 for example RSS can set the proper
// Content-Type header.
$response = new CacheableResponse('', 200);
$build['#response'] = $response;
/** @var \Drupal\Core\Render\RendererInterface $renderer */
$renderer = \Drupal::service('renderer');
$output = (string) $renderer->renderRoot($build);
if (empty($output)) {
throw new NotFoundHttpException();
}
$response->setContent($output);
$cache_metadata = CacheableMetadata::createFromRenderArray($build);
$response->addCacheableDependency($cache_metadata);
// Set the HTTP headers and status code on the response if any bubbled.
if (!empty($build['#attached']['http_header'])) {
static::setHeaders($response, $build['#attached']['http_header']);
}
return $response;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.