function ActiveWorkspaceCheck::access

Same name in other branches
  1. 8.9.x core/modules/workspaces/src/Access/ActiveWorkspaceCheck.php \Drupal\workspaces\Access\ActiveWorkspaceCheck::access()
  2. 10 core/modules/workspaces/src/Access/ActiveWorkspaceCheck.php \Drupal\workspaces\Access\ActiveWorkspaceCheck::access()
  3. 11.x core/modules/workspaces/src/Access/ActiveWorkspaceCheck.php \Drupal\workspaces\Access\ActiveWorkspaceCheck::access()

Checks access.

Parameters

\Symfony\Component\Routing\Route $route: The route to check against.

Return value

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

File

core/modules/workspaces/src/Access/ActiveWorkspaceCheck.php, line 41

Class

ActiveWorkspaceCheck
Determines access to routes based on the presence of an active workspace.

Namespace

Drupal\workspaces\Access

Code

public function access(Route $route) {
    if (!$route->hasRequirement('_has_active_workspace')) {
        return AccessResult::neutral();
    }
    $required_value = filter_var($route->getRequirement('_has_active_workspace'), FILTER_VALIDATE_BOOLEAN);
    return AccessResult::allowedIf($required_value === $this->workspaceManager
        ->hasActiveWorkspace())
        ->addCacheContexts([
        'workspace',
    ]);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.