You are here

public function CartBlock::build in Commerce Cart API 8

Same name in this branch
  1. 8 tests/modules/commerce_cart_js/src/Plugin/Block/CartBlock.php \Drupal\commerce_cart_js\Plugin\Block\CartBlock::build()
  2. 8 tests/modules/commerce_cart_reactjs/src/Plugin/Block/CartBlock.php \Drupal\commerce_cart_reactjs\Plugin\Block\CartBlock::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

tests/modules/commerce_cart_reactjs/src/Plugin/Block/CartBlock.php, line 22

Class

CartBlock
Provides a cart block.

Namespace

Drupal\commerce_cart_reactjs\Plugin\Block

Code

public function build() {
  return [
    '#attached' => [
      'library' => [
        'commerce_cart_reactjs/components',
      ],
    ],
    '#markup' => Markup::create('<div id="reactCartBlock"></div>'),
  ];
}