You are here

public function AddressBookController::checkOverviewAccess in Commerce Core 8.2

Checks access for the overview page.

Grants access if the current user is allowed to view at least one customer profile type.

Parameters

\Drupal\user\UserInterface $user: The user account.

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

Return value

\Drupal\Core\Access\AccessResultInterface The access result.

1 string reference to 'AddressBookController::checkOverviewAccess'
commerce_order.routing.yml in modules/order/commerce_order.routing.yml
modules/order/commerce_order.routing.yml

File

modules/order/src/Controller/AddressBookController.php, line 259

Class

AddressBookController
Provides the address book UI.

Namespace

Drupal\commerce_order\Controller

Code

public function checkOverviewAccess(UserInterface $user, AccountInterface $account) {
  $user_access = $user
    ->access('view', $account, TRUE);
  if (!$user_access
    ->isAllowed()) {

    // The account does not have access to the user's canonical page
    // ("/user/{user}"), don't allow access to any sub-pages either.
    return $user_access;
  }
  $profile_types = $this->addressBook
    ->loadTypes();
  $profile_types = $this
    ->filterTypesByViewAccess($profile_types, $user, $account);
  return AccessResult::allowedIf(!empty($profile_types))
    ->addCacheTags([
    'config:profile_type_list',
  ]);
}