class CronWorkspaceNegotiator in Multiversion 8
Hierarchy
- class \Drupal\multiversion\Workspace\WorkspaceNegotiatorBase implements \Symfony\Component\DependencyInjection\ContainerAwareInterface, WorkspaceNegotiatorInterface uses \Symfony\Component\DependencyInjection\ContainerAwareTrait
- class \Drupal\multiversion\Workspace\CronWorkspaceNegotiator
Expanded class hierarchy of CronWorkspaceNegotiator
1 string reference to 'CronWorkspaceNegotiator'
1 service uses CronWorkspaceNegotiator
File
- src/
Workspace/ CronWorkspaceNegotiator.php, line 9
Namespace
Drupal\multiversion\WorkspaceView source
class CronWorkspaceNegotiator extends WorkspaceNegotiatorBase {
/**
* @var \Drupal\Core\State\StateInterface
*/
private $state;
/**
* Constructor.
*
* @param \Drupal\Core\State\StateInterface $state
*/
public function __construct(StateInterface $state) {
$this->state = $state;
}
/**
* {@inheritdoc}
*/
public function applies(Request $request) {
// This negotiator only applies if the current route is 'system.cron',
// 'system.run_cron' or '<none>';
$route = $request->attributes
->get('_route');
return in_array($route, [
'system.cron',
'system.run_cron',
'<none>',
]);
}
/**
* {@inheritdoc}
*/
public function getWorkspaceId(Request $request) {
$workspace_id = $this->state
->get('workspace.negotiator.cron.active_workspace_id');
return $workspace_id ?: $this->container
->getParameter('workspace.default');
}
/**
* {@inheritdoc}
*/
public function persist(WorkspaceInterface $workspace) {
$this->state
->set('workspace.negotiator.cron.active_workspace_id', $workspace
->id());
return TRUE;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CronWorkspaceNegotiator:: |
private | property | ||
CronWorkspaceNegotiator:: |
public | function |
Overrides WorkspaceNegotiatorInterface:: |
|
CronWorkspaceNegotiator:: |
public | function |
Overrides WorkspaceNegotiatorInterface:: |
|
CronWorkspaceNegotiator:: |
public | function |
Overrides WorkspaceNegotiatorBase:: |
|
CronWorkspaceNegotiator:: |
public | function | Constructor. | |
WorkspaceNegotiatorBase:: |
protected | property | ||
WorkspaceNegotiatorBase:: |
protected | property | ||
WorkspaceNegotiatorBase:: |
public | function |
Overrides WorkspaceNegotiatorInterface:: |
|
WorkspaceNegotiatorBase:: |
public | function |
Overrides WorkspaceNegotiatorInterface:: |