public function CartLinkToken::validate in Commerce Add To Cart Link 8
Same name and namespace in other branches
- 2.x src/CartLinkToken.php \Drupal\commerce_add_to_cart_link\CartLinkToken::validate()
Checks the given token for the given variation for validity.
Parameters
\Drupal\commerce_product\Entity\ProductVariationInterface $variation: The product variation.
string $token: The token to be validated.
Return value
bool TRUE, if the given token is valid, FALSE otherwise.
Overrides CartLinkTokenInterface::validate
File
- src/
CartLinkToken.php, line 83
Class
- CartLinkToken
- Default cart link token service implementation.
Namespace
Drupal\commerce_add_to_cart_linkCode
public function validate(ProductVariationInterface $variation, $token) {
if (!$this
->needsCsrfProtection($this->currentUser)) {
return TRUE;
}
$value = $this
->generateTokenValue($variation);
return $this->csrfTokenGenerator
->validate($token, $value);
}