You are here

class Renderer in Colorbox Load 8

Render content in a colorbox.

Hierarchy

Expanded class hierarchy of Renderer

1 string reference to 'Renderer'
colorbox_load.services.yml in ./colorbox_load.services.yml
colorbox_load.services.yml
1 service uses Renderer
colorbox_load.renderer in ./colorbox_load.services.yml
Drupal\colorbox_load\Renderer

File

src/Renderer.php, line 14

Namespace

Drupal\colorbox_load
View source
class Renderer implements MainContentRendererInterface {

  /**
   * The renderer service.
   *
   * @var \Drupal\Core\Render\RendererInterface
   */
  protected $renderer;

  /**
   * Constructs a new HtmlRenderer.
   *
   * @param \Drupal\Core\Render\RendererInterface $renderer
   *   The renderer service.
   */
  public function __construct(RendererInterface $renderer) {
    $this->renderer = $renderer;
  }

  /**
   * {@inheritdoc}
   */
  public function renderResponse(array $main_content, Request $request, RouteMatchInterface $route_match) {
    $response = new AjaxResponse();
    $content = $this->renderer
      ->renderPlain($main_content);
    $response
      ->setAttachments($main_content['#attached']);
    $response
      ->addCommand(new OpenCommand($content));
    return $response;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Renderer::$renderer protected property The renderer service.
Renderer::renderResponse public function Renders the main content render array into a response. Overrides MainContentRendererInterface::renderResponse
Renderer::__construct public function Constructs a new HtmlRenderer.