public function CartLinkToken::validate in Commerce Add To Cart Link 2.x
Same name and namespace in other branches
- 8 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 68
Class
- CartLinkToken
- Default cart link token service implementation.
Namespace
Drupal\commerce_add_to_cart_linkCode
public function validate(ProductVariationInterface $variation, string $token) {
if (!$this
->needsCsrfProtection($this->currentUser)) {
return TRUE;
}
$value = $this
->generate($variation);
return hash_equals($value, $token);
}