1.20.x layout_renderer_editor.inc LayoutRendererEditor::renderBlock($block)

Render a block using its designated style.

This method also manages 'title block' functionality, where the title from an individual block can be bubbled up to take over the title for the entire display.

Parameters

Block $block: The block to be rendered.

Return value

string: The rendered block as HTML.

Overrides LayoutRendererStandard::renderBlock

File

modules/layout/plugins/renderers/layout_renderer_editor.inc, line 105
Class file to control the main Layout editor.

Class

LayoutRendererEditor

Code

function renderBlock($block) {
  $aria_label = $this->getAriaLabel($block);
  $buttons = $this->getBlockLinks($block);
  $content = $block->getAdminPreview();

  $attributes = array(
    'tabindex' => '0',
    'aria-label' => $aria_label,
    'class' => array('layout-editor-block clearfix'),
    'id' => 'layout-editor-block-' . $block->uuid,
    'data-block-id' => $block->uuid,
  );

  $output = '<div ' . backdrop_attributes($attributes) . '>';
  $output .= '<div class="layout-editor-block-title clearfix">';
  $output .= '<span class="handle"></span><span class="text">' . $block->getAdminTitle() . '</span>';
  if ($buttons) {
    $output .= '<span class="buttons">' . $buttons . '</span>';
  }
  $output .= '</div>'; // layout-block-title
  $output .= '<div tabindex="0" class="layout-editor-block-content">' . render($content) . '</div>';
  $output .= '</div>'; // layout-block

  return $output;
}