You are here

public function WorkspaceNormalizer::normalize in Replication 8

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

Overrides ComplexDataNormalizer::normalize

File

src/Normalizer/WorkspaceNormalizer.php, line 27

Class

WorkspaceNormalizer
@todo {@link https://www.drupal.org/node/2599920 Don't extend EntityNormalizer.}

Namespace

Drupal\replication\Normalizer

Code

public function normalize($entity, $format = NULL, array $context = []) {
  $context['entity_type'] = 'workspace';
  $data = parent::normalize($entity, $format, $context);
  $return_data = [];
  if (isset($data['machine_name'])) {
    $return_data['db_name'] = (string) $entity
      ->getMachineName();
  }
  if ($update_seq = $entity
    ->getUpdateSeq()) {
    $return_data['update_seq'] = (int) $update_seq;
  }
  else {

    // Replicator expects update_seq to be always set.
    $return_data['update_seq'] = 0;
  }
  if (isset($data['created'])) {
    $return_data['instance_start_time'] = (string) $entity
      ->getStartTime();
  }
  return $return_data;
}