You are here

public function ViewsBulkOperationsAccess::access in Views Bulk Operations (VBO) 8

Same name and namespace in other branches
  1. 8.3 src/Access/ViewsBulkOperationsAccess.php \Drupal\views_bulk_operations\Access\ViewsBulkOperationsAccess::access()
  2. 8.2 src/Access/ViewsBulkOperationsAccess.php \Drupal\views_bulk_operations\Access\ViewsBulkOperationsAccess::access()
  3. 4.0.x src/Access/ViewsBulkOperationsAccess.php \Drupal\views_bulk_operations\Access\ViewsBulkOperationsAccess::access()

A custom access check.

Parameters

\Drupal\Core\Session\AccountInterface $account: Run access checks for this account.

\Drupal\Core\Routing\RouteMatch $routeMatch: The matched route.

File

src/Access/ViewsBulkOperationsAccess.php, line 38

Class

ViewsBulkOperationsAccess
Defines module access rules.

Namespace

Drupal\views_bulk_operations\Access

Code

public function access(AccountInterface $account, RouteMatch $routeMatch) {
  $parameters = $routeMatch
    ->getParameters()
    ->all();
  $tempstore_name = 'views_bulk_operations_' . $parameters['view_id'] . '_' . $parameters['display_id'];
  $view_data = $this->tempStoreFactory
    ->get($tempstore_name)
    ->get($account
    ->id());
  if (!empty($view_data)) {
    return AccessResult::allowed();
  }
  return AccessResult::forbidden();
}