public function TcaCommerceProductAccessControlHandler::access in Token Content Access 2.0.x
Same name and namespace in other branches
- 8 modules/tca_commerce_product/src/TcaCommerceProductAccessControlHandler.php \Drupal\tca_commerce_product\TcaCommerceProductAccessControlHandler::access()
File
- modules/
tca_commerce_product/ src/ TcaCommerceProductAccessControlHandler.php, line 18
Class
- TcaCommerceProductAccessControlHandler
- Extended access control handler for node entity.
Namespace
Drupal\tca_commerce_productCode
public function access(EntityInterface $entity, $operation, AccountInterface $account = NULL, $return_as_object = FALSE) {
// Allow users without the permission "access content"
// to 'view' the commerce_product by providing URL token.
$access = parent::access($entity, $operation, $account, $return_as_object);
if ($operation === 'view' && $entity
->get('tca_active')
->getString()) {
// Compare token from URL with commerce_product token.
$token_match = $entity
->get('tca_token')
->getString() === $this
->getRequestStack()
->getCurrentRequest()
->get('tca');
return $token_match ? AccessResultAllowed::allowed() : $access;
}
return $access;
}