public function AddToWishlistLink::metadata in Commerce Add To Cart Link 8
Same name and namespace in other branches
- 2.x modules/wishlist/src/AddToWishlistLink.php \Drupal\commerce_add_to_wishlist_link\AddToWishlistLink::metadata()
Generate metadata for an add-to-cart link.
Return value
\Drupal\Core\Render\BubbleableMetadata The metadata object.
1 call to AddToWishlistLink::metadata()
- AddToWishlistLink::build in modules/
wishlist/ src/ AddToWishlistLink.php - Generate a render array for an add-to-wishlist link.
File
- modules/
wishlist/ src/ AddToWishlistLink.php, line 72
Class
- AddToWishlistLink
- Defines a helper class for constructing add to wishlist links.
Namespace
Drupal\commerce_add_to_wishlist_linkCode
public function metadata() {
/** @var \Drupal\commerce_add_to_cart_link\CartLinkTokenInterface $cart_link_token_service */
$cart_link_token_service = \Drupal::service('commerce_add_to_cart_link.token');
$contexts = $cart_link_token_service
->needsCsrfProtection() ? [
'session',
] : [];
return BubbleableMetadata::createFromRenderArray([
'#cache' => [
'contexts' => $contexts,
'tags' => [
'config:commerce_add_to_cart_link.settings',
],
],
]);
}