You are here

public function PrintableLinksBlock::build in Printer and PDF versions for Drupal 8+ 8

Same name and namespace in other branches
  1. 2.x src/Plugin/Block/PrintableLinksBlock.php \Drupal\printable\Plugin\Block\PrintableLinksBlock::build()

Builds and returns the renderable array for this block plugin.

If a block should not be rendered because it has no content, then this method must also ensure to return no content: it must then only return an empty array, or an empty array with #cache set (with cacheability metadata indicating the circumstances for it being empty).

Return value

array A renderable array representing the content of the block.

Overrides BlockPluginInterface::build

See also

\Drupal\block\BlockViewBuilder

File

src/Plugin/Block/PrintableLinksBlock.php, line 129

Class

PrintableLinksBlock
Provides a printable links block for each printable entity.

Namespace

Drupal\printable\Plugin\Block

Code

public function build() {
  $entity_type = $this
    ->getDerivativeId();
  if ($this->routematch
    ->getMasterRouteMatch()
    ->getParameter($entity_type)) {
    return [
      '#theme' => 'links__entity__printable',
      '#links' => $this->linkBuilder
        ->buildLinks($this->routematch
        ->getMasterRouteMatch()
        ->getParameter($entity_type)),
    ];
  }
}