class DefaultWorkspaceNegotiator in Workspace 8.2
Defines the default workspace negotiator.
Hierarchy
- class \Drupal\workspace\Negotiator\DefaultWorkspaceNegotiator implements WorkspaceNegotiatorInterface
Expanded class hierarchy of DefaultWorkspaceNegotiator
1 string reference to 'DefaultWorkspaceNegotiator'
1 service uses DefaultWorkspaceNegotiator
File
- src/
Negotiator/ DefaultWorkspaceNegotiator.php, line 13
Namespace
Drupal\workspace\NegotiatorView source
class DefaultWorkspaceNegotiator implements WorkspaceNegotiatorInterface {
/**
* The workspace storage handler.
*
* @var \Drupal\Core\Entity\EntityStorageInterface
*/
protected $workspaceStorage;
/**
* The default workspace entity.
*
* @var \Drupal\workspace\WorkspaceInterface
*/
protected $defaultWorkspace;
/**
* Constructor.
*
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager.
*/
public function __construct(EntityTypeManagerInterface $entity_type_manager) {
$this->workspaceStorage = $entity_type_manager
->getStorage('workspace');
}
/**
* {@inheritdoc}
*/
public function applies(Request $request) {
return TRUE;
}
/**
* {@inheritdoc}
*/
public function getActiveWorkspace(Request $request) {
if (!$this->defaultWorkspace) {
$default_workspace = $this->workspaceStorage
->create([
'id' => WorkspaceInterface::DEFAULT_WORKSPACE,
'label' => Unicode::ucwords(WorkspaceInterface::DEFAULT_WORKSPACE),
'target' => '',
]);
$default_workspace
->enforceIsNew(FALSE);
$this->defaultWorkspace = $default_workspace;
}
return $this->defaultWorkspace;
}
/**
* {@inheritdoc}
*/
public function setActiveWorkspace(WorkspaceInterface $workspace) {
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DefaultWorkspaceNegotiator:: |
protected | property | The default workspace entity. | |
DefaultWorkspaceNegotiator:: |
protected | property | The workspace storage handler. | |
DefaultWorkspaceNegotiator:: |
public | function |
Checks whether the negotiator applies to the current request or not. Overrides WorkspaceNegotiatorInterface:: |
|
DefaultWorkspaceNegotiator:: |
public | function |
Gets the negotiated workspace, if any. Overrides WorkspaceNegotiatorInterface:: |
|
DefaultWorkspaceNegotiator:: |
public | function |
Sets the negotiated workspace. Overrides WorkspaceNegotiatorInterface:: |
|
DefaultWorkspaceNegotiator:: |
public | function | Constructor. |