You are here

public function MultiversionIndexFactory::get in Multiversion 8

Same name and namespace in other branches
  1. 8.2 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, WorkspaceInterface $workspace = null) {
  $index = $this->container
    ->get($service . '.scope');
  if ($index instanceof IndexInterface) {
    $workspace_id = $workspace ? $workspace
      ->id() : $this->workspaceManager
      ->getActiveWorkspaceId();
    return $indexes[$workspace_id][$service] = $index
      ->useWorkspace($workspace_id);
  }
  else {
    throw new \InvalidArgumentException("Service {$service} is not an instance of IndexInterface.");
  }
}