You are here

class MultiversionIndexFactory in Multiversion 8.2

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

Hierarchy

Expanded class hierarchy of MultiversionIndexFactory

1 string reference to 'MultiversionIndexFactory'
multiversion.services.yml in ./multiversion.services.yml
multiversion.services.yml
1 service uses MultiversionIndexFactory
multiversion.entity_index.factory in ./multiversion.services.yml
Drupal\multiversion\Entity\Index\MultiversionIndexFactory

File

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

Namespace

Drupal\multiversion\Entity\Index
View 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

Namesort descending Modifiers Type Description Overrides
MultiversionIndexFactory::$container protected property @var ContainerInterface
MultiversionIndexFactory::$indexes protected property @var EntityIndexInterface[]
MultiversionIndexFactory::$workspaceManager protected property @var WorkspaceManagerInterface
MultiversionIndexFactory::get public function
MultiversionIndexFactory::__construct public function