You are here

protected function PanelsIPEBlockRendererTrait::buildBlockInstance in Panels 8.4

Same name and namespace in other branches
  1. 8.3 panels_ipe/src/PanelsIPEBlockRendererTrait.php \Drupal\panels_ipe\PanelsIPEBlockRendererTrait::buildBlockInstance()

Compiles a render array for the given Block instance based on the form.

Parameters

\Drupal\Core\Block\BlockBase $block_instance: The Block instance you want to render.

\Drupal\panels\Plugin\DisplayVariant\PanelsDisplayVariant $panels_display: The Panels Display that contains the Block instance.

Return value

array $build The Block render array.

3 calls to PanelsIPEBlockRendererTrait::buildBlockInstance()
PanelsIPEBlockPluginForm::submitForm in panels_ipe/src/Form/PanelsIPEBlockPluginForm.php
Form submission handler.
PanelsIPEBlockPluginForm::submitPreview in panels_ipe/src/Form/PanelsIPEBlockPluginForm.php
Previews our current Block configuration.
PanelsIPEPageController::getBlockModelData in panels_ipe/src/Controller/PanelsIPEPageController.php
Gets a single Block from the current Panels Display as data. Uses TempStore.

File

panels_ipe/src/PanelsIPEBlockRendererTrait.php, line 29

Class

PanelsIPEBlockRendererTrait
Provides methods to render Blocks for display in Panels IPE.

Namespace

Drupal\panels_ipe

Code

protected function buildBlockInstance($block_instance, $panels_display) {

  // Get the new block configuration.
  $configuration = $block_instance
    ->getConfiguration();

  // Add context to the block.
  if ($this->contextHandler && $block_instance instanceof ContextAwarePluginInterface) {
    $this->contextHandler
      ->applyContextMapping($block_instance, $panels_display
      ->getContexts());
  }

  // Build the block content.
  $content = $block_instance
    ->build();

  // Compile the render array.
  $build = [
    '#theme' => 'block',
    '#attributes' => [],
    '#contextual_links' => [],
    '#configuration' => $configuration,
    '#plugin_id' => $block_instance
      ->getPluginId(),
    '#base_plugin_id' => $block_instance
      ->getBaseId(),
    '#derivative_plugin_id' => $block_instance
      ->getDerivativeId(),
    'content' => $content,
  ];
  return $build;
}