protected function EntityIndex::buildValue in Multiversion 8
Same name and namespace in other branches
- 8.2 src/Entity/Index/EntityIndex.php \Drupal\multiversion\Entity\Index\EntityIndex::buildValue()
Helper method for building the value to be indexed.
Parameters
\Drupal\Core\Entity\EntityInterface $entity:
Return value
array
1 call to EntityIndex::buildValue()
- EntityIndex::addMultiple in src/Entity/ Index/ EntityIndex.php 
File
- src/Entity/ Index/ EntityIndex.php, line 128 
Class
Namespace
Drupal\multiversion\Entity\IndexCode
protected function buildValue(EntityInterface $entity) {
  !($is_new = $entity
    ->isNew());
  $revision_id = $is_new ? 0 : $entity
    ->getRevisionId();
  // We assign a temporary status to the revision since we are indexing it
  // pre save. It will be updated post save with the final status. This will
  // help identifying failures and exception scenarios during entity save.
  $status = 'indexed';
  if (!$is_new && $revision_id) {
    $status = $entity->_deleted->value ? 'deleted' : 'available';
  }
  return [
    'entity_type_id' => $entity
      ->getEntityTypeId(),
    'entity_id' => $is_new ? 0 : $entity
      ->id(),
    'revision_id' => $revision_id,
    'uuid' => $entity
      ->uuid(),
    'rev' => $entity->_rev->value,
    'is_stub' => $entity->_rev->is_stub,
    'status' => $status,
  ];
}