You are here

ViewsMegarowResponseRenderer.php in Views Megarow 8

File

src/Core/ViewsMegarowResponseRenderer.php
View source
<?php

namespace Drupal\views_megarow\Core;

use Symfony\Component\HttpFoundation\Request;
use Drupal\Core\Render\MainContent\HtmlRenderer;
use Drupal\Core\Routing\RouteMatchInterface;
use Symfony\Component\HttpFoundation\Response;

/**
 * Converts a controller result into an Views Megarow response object.
 */
class ViewsMegarowResponseRenderer extends HtmlRenderer {

  /**
   * {@inheritdoc}
   *
   * The entire HTML: takes a #type 'page' and wraps it in a #type 'html'.
   */
  public function renderResponse(array $main_content, Request $request, RouteMatchInterface $route_match) {
    $content = $this->renderer
      ->render($main_content);

    // Set the generator in the HTTP header.
    list($version) = explode('.', \Drupal::VERSION, 2);
    return new Response($content, 200, [
      'X-Generator' => 'Drupal ' . $version . ' (http://drupal.org)',
    ]);
  }

}

Classes

Namesort descending Description
ViewsMegarowResponseRenderer Converts a controller result into an Views Megarow response object.