You are here

public function MultiversionIndexFactory::get in Multiversion 8.2

Same name and namespace in other branches
  1. 8 src/Entity/Index/MultiversionIndexFactory.php \Drupal\multiversion\Entity\Index\MultiversionIndexFactory::get()

File

src/Entity/Index/MultiversionIndexFactory.php, line 25

Class

MultiversionIndexFactory

Namespace

Drupal\multiversion\Entity\Index

Code

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.");
  }
}