function AttachedRenderingBlock::build

Same name in other branches
  1. 8.9.x core/modules/system/tests/modules/render_attached_test/src/Plugin/Block/AttachedRenderingBlock.php \Drupal\render_attached_test\Plugin\Block\AttachedRenderingBlock::build()
  2. 10 core/modules/system/tests/modules/render_attached_test/src/Plugin/Block/AttachedRenderingBlock.php \Drupal\render_attached_test\Plugin\Block\AttachedRenderingBlock::build()
  3. 11.x core/modules/system/tests/modules/render_attached_test/src/Plugin/Block/AttachedRenderingBlock.php \Drupal\render_attached_test\Plugin\Block\AttachedRenderingBlock::build()

Overrides BlockPluginInterface::build

File

core/modules/system/tests/modules/render_attached_test/src/Plugin/Block/AttachedRenderingBlock.php, line 25

Class

AttachedRenderingBlock
A block we can use to test caching of #attached headers.

Namespace

Drupal\render_attached_test\Plugin\Block

Code

public function build() {
    // Grab test attachment fixtures from
    // Drupal\render_attached_test\Controller\RenderAttachedTestController.
    $controller = new RenderAttachedTestController();
    $attached = BubbleableMetadata::mergeAttachments($controller->feed(), $controller->head());
    $attached = BubbleableMetadata::mergeAttachments($attached, $controller->header());
    $attached = BubbleableMetadata::mergeAttachments($attached, $controller->teapotHeaderStatus());
    // Return some arbitrary markup so the block doesn't disappear.
    $attached['#markup'] = 'Markup from attached_rendering_block.';
    return $attached;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.