3 namespace Drupal\workspaces\Negotiator;
5 use Drupal\Component\Utility\Unicode;
6 use Drupal\Core\Entity\EntityTypeManagerInterface;
7 use Drupal\workspaces\WorkspaceInterface;
8 use Symfony\Component\HttpFoundation\Request;
11 * Defines the default workspace negotiator.
13 class DefaultWorkspaceNegotiator implements WorkspaceNegotiatorInterface {
16 * The workspace storage handler.
18 * @var \Drupal\Core\Entity\EntityStorageInterface
20 protected $workspaceStorage;
23 * The default workspace entity.
25 * @var \Drupal\workspaces\WorkspaceInterface
27 protected $defaultWorkspace;
32 * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
33 * The entity type manager.
35 public function __construct(EntityTypeManagerInterface $entity_type_manager) {
36 $this->workspaceStorage = $entity_type_manager->getStorage('workspace');
42 public function applies(Request $request) {
49 public function getActiveWorkspace(Request $request) {
50 if (!$this->defaultWorkspace) {
51 $default_workspace = $this->workspaceStorage->create([
52 'id' => WorkspaceInterface::DEFAULT_WORKSPACE,
53 'label' => Unicode::ucwords(WorkspaceInterface::DEFAULT_WORKSPACE),
55 $default_workspace->enforceIsNew(FALSE);
57 $this->defaultWorkspace = $default_workspace;
60 return $this->defaultWorkspace;
66 public function setActiveWorkspace(WorkspaceInterface $workspace) {}