You are here

public function CartBlock::build in Commerce Cart Blocks 8

Builds the cart block.

Return value

array A render array.

Overrides BlockPluginInterface::build

1 method overrides CartBlock::build()
CartButtonBlock::build in src/Plugin/Block/CartButtonBlock.php
Builds the cart block.

File

src/Plugin/Block/CartBlock.php, line 78

Class

CartBlock
Provides a cart block.

Namespace

Drupal\commerce_cart_blocks\Plugin\Block

Code

public function build() {
  if ($this
    ->shouldHide()) {
    return [];
  }
  return [
    '#attached' => [
      'library' => $this
        ->getLibraries(),
    ],
    '#theme' => 'commerce_cart_blocks_cart',
    '#count' => $this
      ->getCartCount(),
    '#heading' => $this
      ->buildHeading(),
    '#content' => $this
      ->buildItems(),
    '#links' => $this
      ->buildLinks(),
    '#in_cart' => $this
      ->isInCart(),
    '#cache' => $this
      ->buildCache(),
  ];
}