class ActiveWorkspaceCheck
Same name in other branches
- 9 core/modules/workspaces/src/Access/ActiveWorkspaceCheck.php \Drupal\workspaces\Access\ActiveWorkspaceCheck
- 8.9.x core/modules/workspaces/src/Access/ActiveWorkspaceCheck.php \Drupal\workspaces\Access\ActiveWorkspaceCheck
- 10 core/modules/workspaces/src/Access/ActiveWorkspaceCheck.php \Drupal\workspaces\Access\ActiveWorkspaceCheck
Determines access to routes based on the presence of an active workspace.
Hierarchy
- class \Drupal\workspaces\Access\ActiveWorkspaceCheck implements \Drupal\Core\Routing\Access\AccessInterface
Expanded class hierarchy of ActiveWorkspaceCheck
1 file declares its use of ActiveWorkspaceCheck
- ActiveWorkspaceCheckTest.php in core/
modules/ workspaces/ tests/ src/ Unit/ ActiveWorkspaceCheckTest.php
1 string reference to 'ActiveWorkspaceCheck'
- workspaces.services.yml in core/
modules/ workspaces/ workspaces.services.yml - core/modules/workspaces/workspaces.services.yml
1 service uses ActiveWorkspaceCheck
- access_check.workspaces.active_workspace in core/
modules/ workspaces/ workspaces.services.yml - Drupal\workspaces\Access\ActiveWorkspaceCheck
File
-
core/
modules/ workspaces/ src/ Access/ ActiveWorkspaceCheck.php, line 13
Namespace
Drupal\workspaces\AccessView source
class ActiveWorkspaceCheck implements AccessInterface {
/**
* The workspace manager.
*
* @var \Drupal\workspaces\WorkspaceManagerInterface
*/
protected $workspaceManager;
/**
* Constructs a new ActiveWorkspaceCheck.
*
* @param \Drupal\workspaces\WorkspaceManagerInterface $workspace_manager
* The workspace manager.
*/
public function __construct(WorkspaceManagerInterface $workspace_manager) {
$this->workspaceManager = $workspace_manager;
}
/**
* Checks access.
*
* @param \Symfony\Component\Routing\Route $route
* The route to check against.
*
* @return \Drupal\Core\Access\AccessResultInterface
* The access result.
*/
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',
]);
}
}
Members
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
ActiveWorkspaceCheck::$workspaceManager | protected | property | The workspace manager. |
ActiveWorkspaceCheck::access | public | function | Checks access. |
ActiveWorkspaceCheck::__construct | public | function | Constructs a new ActiveWorkspaceCheck. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.