public function Ng2Block::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_ng2/ src/ Plugin/ Block/ Ng2Block.php, line 21
Class
- Ng2Block
- Exposes an Angular 2 component as a block.
Namespace
Drupal\pdb_ng2\Plugin\BlockCode
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-' . $this->configuration['uuid'] . '"></' . $machine_name . '>';
return $build;
}