public function WishlistBlock::build in Commerce Wishlist 8.3
Builds the wishlist block.
Return value
array A render array.
Overrides BlockPluginInterface::build
File
- src/
Plugin/ Block/ WishlistBlock.php, line 66
Class
- WishlistBlock
- Provides a wishlist block.
Namespace
Drupal\commerce_wishlist\Plugin\BlockCode
public function build() {
/** @var \Drupal\commerce_wishlist\Entity\WishlistInterface[] $wishlists */
$wishlist = $this->wishlistProvider
->getWishlist('default');
$count = $wishlist ? count($wishlist
->getItems()) : 0;
return [
'#theme' => 'commerce_wishlist_block',
'#count' => $count,
'#count_text' => $this
->formatPlural($count, '@count item', '@count items', [], [
'context' => 'wishlist block',
]),
'#wishlist_entity' => $wishlist,
'#url' => Url::fromRoute('commerce_wishlist.page'),
];
}