You are here

public function EntityIndex::addMultiple in Multiversion 8.2

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

Parameters

array $entities:

Overrides EntityIndexInterface::addMultiple

1 call to EntityIndex::addMultiple()
EntityIndex::add in src/Entity/Index/EntityIndex.php

File

src/Entity/Index/EntityIndex.php, line 84

Class

EntityIndex

Namespace

Drupal\multiversion\Entity\Index

Code

public function addMultiple(array $entities) {
  $workspace_id = $this
    ->getWorkspaceId();
  $values = [];

  /** @var ContentEntityInterface $entity */
  foreach ($entities as $entity) {
    $key = $this
      ->buildKey($entity);
    $value = $this
      ->buildValue($entity);
    if ($entity
      ->getEntityType()
      ->get('workspace') === FALSE) {
      $values[0][$key] = $value;
    }
    else {
      $values[$workspace_id][$key] = $value;
    }
  }
  foreach ($values as $workspace_id => $value) {
    $this
      ->keyValueStore($workspace_id)
      ->setMultiple($value);
  }
}