You are here

public function EmberBlock::build in Decoupled Blocks 8

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 PdbBlock::build

See also

\Drupal\block\BlockViewBuilder

File

modules/pdb_ember/src/Plugin/Block/EmberBlock.php, line 21

Class

EmberBlock
Exposes an Ember component as a block.

Namespace

Drupal\pdb_ember\Plugin\Block

Code

public function build() {
  $info = $this
    ->getComponentInfo();
  $machine_name = $info['machine_name'];
  $build = parent::build();
  $build['#allowed_tags'] = [
    $machine_name,
  ];
  $build['#markup'] = '<' . $machine_name . ' id="instance-id-' . $machine_name . '">Test</' . $machine_name . '>';
  return $build;
}