function Feed::buildResponse
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
- 
              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.
