Renderer.php 760 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. /**
  3. * @file
  4. * Contains \Drupal\colorbox_load\Renderer.
  5. */
  6. namespace Drupal\colorbox_load;
  7. use Drupal\Core\Ajax\AjaxResponse;
  8. use Drupal\Core\Render\MainContent\MainContentRendererInterface;
  9. use Drupal\Core\Routing\RouteMatchInterface;
  10. use Symfony\Component\HttpFoundation\Request;
  11. /**
  12. * Render content in a colorbox.
  13. */
  14. class Renderer implements MainContentRendererInterface {
  15. /**
  16. * {@inheritdoc}
  17. */
  18. public function renderResponse(array $main_content, Request $request, RouteMatchInterface $route_match) {
  19. $response = new AjaxResponse();
  20. $content = drupal_render_root($main_content);
  21. $response->setAttachments($main_content['#attached']);
  22. $response->addCommand(new OpenCommand($content));
  23. return $response;
  24. }
  25. }