You are here

public function RenderCheeseburgerMenuBlock::content in Cheeseburger Menu 8.2

Same name and namespace in other branches
  1. 8.4 src/Controller/RenderCheeseburgerMenuBlock.php \Drupal\cheeseburger_menu\Controller\RenderCheeseburgerMenuBlock::content()
  2. 8 src/Controller/renderCheeseburgerMenuBlock.php \Drupal\cheeseburger_menu\Controller\renderCheeseburgerMenuBlock::content()
  3. 8.3 src/Controller/RenderCheeseburgerMenuBlock.php \Drupal\cheeseburger_menu\Controller\RenderCheeseburgerMenuBlock::content()
1 string reference to 'RenderCheeseburgerMenuBlock::content'
cheeseburger_menu.routing.yml in ./cheeseburger_menu.routing.yml
cheeseburger_menu.routing.yml

File

src/Controller/RenderCheeseburgerMenuBlock.php, line 90
Controller used for rendering block.

Class

RenderCheeseburgerMenuBlock
Class RenderCheeseburgerMenuBlock.

Namespace

Drupal\cheeseburger_menu\Controller

Code

public function content(Request $request) {
  $block_id = $request->request
    ->get('block_id');
  $route_id = $request->request
    ->get('route_id');
  $page_type = $request->request
    ->get('page_type');
  $current_route = $request->request
    ->get('current_route');
  $block = Block::load($block_id);
  if (!$block) {
    return new Response('<div>No such block</div>');
  }
  $config = $block
    ->get('settings');
  $tree = $this
    ->renderTree($route_id, $page_type, $current_route, $config);

  /** @var \Drupal\Core\Render\Renderer $renderer */
  $renderer = $this->renderer;
  $rendered_tree = $renderer
    ->render($tree);
  return new Response($rendered_tree);
}