protected function PanelsIPEBlockRendererTrait::buildBlockInstance in Panels 8.3
Same name and namespace in other branches
- 8.4 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::getBlock in panels_ipe/
src/ Controller/ PanelsIPEPageController.php - Gets a single Block from the current Panels Display. Uses TempStore.
File
- panels_ipe/
src/ PanelsIPEBlockRendererTrait.php, line 33
Class
- PanelsIPEBlockRendererTrait
- Provides methods to render Blocks for display in Panels IPE.
Namespace
Drupal\panels_ipeCode
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;
}