You are here

public function AddToWishlistLink::build in Commerce Add To Cart Link 2.x

Same name and namespace in other branches
  1. 8 modules/wishlist/src/AddToWishlistLink.php \Drupal\commerce_add_to_wishlist_link\AddToWishlistLink::build()

Generate a render array for an add-to-wishlist link.

Return value

array The render array.

File

modules/wishlist/src/AddToWishlistLink.php, line 37

Class

AddToWishlistLink
Defines a helper class for constructing add to wishlist links.

Namespace

Drupal\commerce_add_to_wishlist_link

Code

public function build() {
  $build = [
    '#theme' => 'commerce_add_to_wishlist_link',
    '#url' => $this
      ->url(),
    '#product_variation' => $this->variation,
  ];
  $metadata = $this
    ->metadata();
  $metadata
    ->applyTo($build);
  return $build;
}