You are here

public function UserEntityNormalizer::denormalize in Content Synchronization 8.2

Same name and namespace in other branches
  1. 3.0.x src/Normalizer/UserEntityNormalizer.php \Drupal\content_sync\Normalizer\UserEntityNormalizer::denormalize()

Overrides ContentEntityNormalizer::denormalize

File

src/Normalizer/UserEntityNormalizer.php, line 21

Class

UserEntityNormalizer
User entity normalizer class.

Namespace

Drupal\content_sync\Normalizer

Code

public function denormalize($data, $class, $format = NULL, array $context = []) {
  $entity = parent::denormalize($data, $class, $format, $context);

  // For security reasons the user 1 is not updated.
  if ((int) $entity
    ->id() === 1) {
    return $entity
      ->load(1);
  }

  // User 0 is not updated.
  if (!empty($data['_content_sync']['is_anonymous']) && (int) $entity
    ->id() === 0) {
    return $entity
      ->load(0);
  }
  return $entity;
}