public function AddToCartLink::metadata in Commerce Add To Cart Link 8
Same name and namespace in other branches
- 2.x src/AddToCartLink.php \Drupal\commerce_add_to_cart_link\AddToCartLink::metadata()
Generate metadata for an add-to-cart link.
Return value
\Drupal\Core\Render\BubbleableMetadata The metadata object.
1 call to AddToCartLink::metadata()
- AddToCartLink::build in src/
AddToCartLink.php - Generate a render array for an add-to-cart link.
File
- src/
AddToCartLink.php, line 91
Class
- AddToCartLink
- Defines a helper class for constructing add to cart links.
Namespace
Drupal\commerce_add_to_cart_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',
],
],
]);
}