You are here

private function Blocks::renderBlock in DRD Agent 8.3

Same name and namespace in other branches
  1. 4.0.x src/Agent/Action/Blocks.php \Drupal\drd_agent\Agent\Action\Blocks::renderBlock()

Load and return the rendered block.

Parameters

string $delta: ID of the block from the given provider.

Return value

\Drupal\Component\Render\MarkupInterface|array Rendered result of the block or an empty array.

1 call to Blocks::renderBlock()
Blocks::execute in src/Agent/Action/Blocks.php
Execute an action.

File

src/Agent/Action/Blocks.php, line 48

Class

Blocks
Provides a 'Blocks' code.

Namespace

Drupal\drd_agent\Agent\Action

Code

private function renderBlock($delta) {
  try {
    $blb = BlockListBuilder::createInstance($this->container, $this->entityTypeManager
      ->getDefinition('block'));
  } catch (PluginNotFoundException $e) {
    return [];
  }

  /** @var \Drupal\block\BlockInterface[] $blocks */
  $blocks = $blb
    ->load();
  if (isset($blocks[$delta])) {
    $block = $blocks[$delta];
    $build = $block
      ->getPlugin()
      ->build();

    /** @noinspection NullPointerExceptionInspection */
    return $this->container
      ->get('renderer')
      ->renderPlain($build);
  }
  return [];
}