public function AddToCartLink::url 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::url()
Generate an URL object for an add-to-cart link.
Return value
\Drupal\Core\Url The URL object.
1 call to AddToCartLink::url()
- AddToCartLink::build in src/
AddToCartLink.php - Generate a render array for an add-to-cart link.
File
- src/
AddToCartLink.php, line 73
Class
- AddToCartLink
- Defines a helper class for constructing add to cart links.
Namespace
Drupal\commerce_add_to_cart_linkCode
public function url() {
/** @var \Drupal\commerce_add_to_cart_link\CartLinkTokenInterface $cart_link_token_service */
$cart_link_token_service = \Drupal::service('commerce_add_to_cart_link.token');
return Url::fromRoute('commerce_add_to_cart_link.page', [
'commerce_product' => $this->variation
->getProductId(),
'commerce_product_variation' => $this->variation
->id(),
'token' => $cart_link_token_service
->generate($this->variation),
]);
}