class SessionWorkspaceNegotiator in Multiversion 8
Hierarchy
- class \Drupal\multiversion\Workspace\WorkspaceNegotiatorBase implements \Symfony\Component\DependencyInjection\ContainerAwareInterface, WorkspaceNegotiatorInterface uses \Symfony\Component\DependencyInjection\ContainerAwareTrait
- class \Drupal\multiversion\Workspace\SessionWorkspaceNegotiator
Expanded class hierarchy of SessionWorkspaceNegotiator
1 string reference to 'SessionWorkspaceNegotiator'
1 service uses SessionWorkspaceNegotiator
File
- src/
Workspace/ SessionWorkspaceNegotiator.php, line 9
Namespace
Drupal\multiversion\WorkspaceView source
class SessionWorkspaceNegotiator extends WorkspaceNegotiatorBase {
/**
* @var \Drupal\user\PrivateTempStore
*/
protected $tempstore;
/**
* Constructor.
*
* @param \Drupal\user\PrivateTempStoreFactory $tempstore_factory
*/
public function __construct(PrivateTempStoreFactory $tempstore_factory) {
$this->tempstore = $tempstore_factory
->get('workspace.negotiator.session');
}
/**
* {@inheritdoc}
*/
public function applies(Request $request) {
// This negotiator only applies if the current user is authenticated,
// i.e. a session exists.
return $this->currentUser
->isAuthenticated();
}
/**
* {@inheritdoc}
*/
public function getWorkspaceId(Request $request) {
$workspace_id = $this->tempstore
->get('active_workspace_id');
return $workspace_id ?: $this->container
->getParameter('workspace.default');
}
/**
* {@inheritdoc}
*/
public function persist(WorkspaceInterface $workspace) {
$this->tempstore
->set('active_workspace_id', $workspace
->id());
return TRUE;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
SessionWorkspaceNegotiator:: |
protected | property | ||
SessionWorkspaceNegotiator:: |
public | function |
Overrides WorkspaceNegotiatorInterface:: |
|
SessionWorkspaceNegotiator:: |
public | function |
Overrides WorkspaceNegotiatorInterface:: |
|
SessionWorkspaceNegotiator:: |
public | function |
Overrides WorkspaceNegotiatorBase:: |
|
SessionWorkspaceNegotiator:: |
public | function | Constructor. | |
WorkspaceNegotiatorBase:: |
protected | property | ||
WorkspaceNegotiatorBase:: |
protected | property | ||
WorkspaceNegotiatorBase:: |
public | function |
Overrides WorkspaceNegotiatorInterface:: |
|
WorkspaceNegotiatorBase:: |
public | function |
Overrides WorkspaceNegotiatorInterface:: |