class MultiversionIndexFactory in Multiversion 8.2
Same name and namespace in other branches
- 8 src/Entity/Index/MultiversionIndexFactory.php \Drupal\multiversion\Entity\Index\MultiversionIndexFactory
Hierarchy
- class \Drupal\multiversion\Entity\Index\MultiversionIndexFactory
Expanded class hierarchy of MultiversionIndexFactory
1 string reference to 'MultiversionIndexFactory'
1 service uses MultiversionIndexFactory
File
- src/
Entity/ Index/ MultiversionIndexFactory.php, line 9
Namespace
Drupal\multiversion\Entity\IndexView source
class MultiversionIndexFactory {
/** @var ContainerInterface */
protected $container;
/** @var WorkspaceManagerInterface */
protected $workspaceManager;
/** @var EntityIndexInterface[] */
protected $indexes = [];
public function __construct(ContainerInterface $container, WorkspaceManagerInterface $workspace_manager) {
$this->container = $container;
$this->workspaceManager = $workspace_manager;
}
public function get($service, Workspace $workspace = null) {
$index = $this->container
->get($service . '.scope');
if ($index instanceof IndexInterface) {
$workspace_id = $workspace ? $workspace
->id() : $this->workspaceManager
->getActiveWorkspace()
->id();
return $indexes[$workspace_id][$service] = $index
->useWorkspace($workspace_id);
}
else {
throw new \InvalidArgumentException("Service {$service} is not an instance of IndexInterface.");
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
MultiversionIndexFactory:: |
protected | property | @var ContainerInterface | |
MultiversionIndexFactory:: |
protected | property | @var EntityIndexInterface[] | |
MultiversionIndexFactory:: |
protected | property | @var WorkspaceManagerInterface | |
MultiversionIndexFactory:: |
public | function | ||
MultiversionIndexFactory:: |
public | function |