public function CartButtonBlock::build in Commerce Cart Blocks 8
Builds the cart block.
Return value
array A render array.
Overrides CartBlock::build
File
- src/
Plugin/ Block/ CartButtonBlock.php, line 88
Class
- CartButtonBlock
- Provides a cart block.
Namespace
Drupal\commerce_cart_blocks\Plugin\BlockCode
public function build() {
if ($this
->shouldHide()) {
return [];
}
$content = [];
if ($this->configuration['dropdown']) {
$content = [
'#theme' => 'commerce_cart_blocks_cart',
'#count' => $this
->getCartCount(),
'#heading' => $this
->buildHeading(),
'#content' => $this
->getCartViews(),
'#links' => $this
->buildLinks(),
];
}
return [
'#attached' => [
'library' => $this
->getLibraries(),
],
'#theme' => 'commerce_cart_blocks_cart_button',
'#count' => $this
->getCartCount(),
'#button_label' => $this
->getButtonLabel(),
'#in_cart' => $this
->isInCart(),
'#icon' => $this
->buildIcon(),
'#url' => Url::fromRoute('commerce_cart.page')
->toString(),
'#content' => $content,
'#cache' => $this
->buildCache(),
];
}