You are here

public function OrderUserViewAccessCheck::checkAccess in Commerce Core 8.2

Checks access to an order's user view mode.

Draft orders are always denied as they have not yet been placed. Otherwise access is delegated to entity access checks.

Parameters

\Drupal\Core\Routing\RouteMatchInterface $route_match: The route match.

\Drupal\Core\Session\AccountInterface $account: The currently logged in account.

1 string reference to 'OrderUserViewAccessCheck::checkAccess'
commerce_order.routing.yml in modules/order/commerce_order.routing.yml
modules/order/commerce_order.routing.yml

File

modules/order/src/Access/OrderUserViewAccessCheck.php, line 24

Class

OrderUserViewAccessCheck

Namespace

Drupal\commerce_order\Access

Code

public function checkAccess(RouteMatchInterface $route_match, AccountInterface $account) {
  $order = $route_match
    ->getParameter('commerce_order');
  if (!$order instanceof OrderInterface) {
    return AccessResult::neutral();
  }
  if ($order
    ->getState()
    ->getId() === 'draft') {
    return AccessResult::forbidden()
      ->addCacheableDependency($order);
  }
  return $order
    ->access('view', $account, TRUE);
}