public function EntityIndex::addMultiple in Multiversion 8
Same name and namespace in other branches
- 8.2 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
Namespace
Drupal\multiversion\Entity\IndexCode
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);
}
}