You are here

public function UserEntityNormalizer::normalize 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::normalize()

Overrides ContentEntityNormalizer::normalize

File

src/Normalizer/UserEntityNormalizer.php, line 39

Class

UserEntityNormalizer
User entity normalizer class.

Namespace

Drupal\content_sync\Normalizer

Code

public function normalize($object, $format = NULL, array $context = []) {
  $normalized_data = parent::normalize($object, $format, $context);
  if (!empty($context['content_sync'])) {
    $normalized_data['pass'] = [
      [
        'value' => $object
          ->getPassword(),
        'pre_hashed' => TRUE,
      ],
    ];
    $normalized_data['mail'] = [
      'value' => $object
        ->getEmail(),
    ];
    $normalized_data['status'] = [
      'value' => $object
        ->get('status')->value,
    ];
    $normalized_data['roles'] = $object
      ->getRoles();
  }
  return $normalized_data;
}