You are here

public function ReplicationLogNormalizer::normalize in Replication 8

Same name and namespace in other branches
  1. 8.2 src/Normalizer/ReplicationLogNormalizer.php \Drupal\replication\Normalizer\ReplicationLogNormalizer::normalize()

File

src/Normalizer/ReplicationLogNormalizer.php, line 43

Class

ReplicationLogNormalizer

Namespace

Drupal\replication\Normalizer

Code

public function normalize($entity, $format = NULL, array $context = []) {

  // Strictly format the entity how CouchDB expects it, plus our JSON-LD data.
  $data = [
    '@context' => [
      '_id' => '@id',
    ],
    '@type' => 'replication_log',
    '_id' => '_local/' . $entity
      ->uuid(),
    '_rev' => $entity->_rev->value,
    'history' => $this->serializer
      ->normalize($entity
      ->get('history'), $format, $context),
    'session_id' => $entity
      ->getSessionId(),
    'source_last_seq' => $entity
      ->getSourceLastSeq(),
  ];
  return $data;
}