function SerializationTestNormalizer::normalize

Same name and namespace in other branches
  1. 11.x core/modules/serialization/tests/serialization_test/src/SerializationTestNormalizer.php \Drupal\serialization_test\SerializationTestNormalizer::normalize()
  2. 10 core/modules/serialization/tests/serialization_test/src/SerializationTestNormalizer.php \Drupal\serialization_test\SerializationTestNormalizer::normalize()
  3. 9 core/modules/serialization/tests/serialization_test/src/SerializationTestNormalizer.php \Drupal\serialization_test\SerializationTestNormalizer::normalize()
  4. 8.9.x core/modules/serialization/tests/serialization_test/src/SerializationTestNormalizer.php \Drupal\serialization_test\SerializationTestNormalizer::normalize()

Normalizes data into a set of arrays/scalars.

Parameters

object $object: Data to normalize.

string|null $format: Format the normalization result will be encoded as.

array<string, mixed> $context: Context options for the normalizer.

Return value

array The normalized data.

File

core/modules/serialization/tests/serialization_test/src/SerializationTestNormalizer.php, line 34

Class

SerializationTestNormalizer
Serialization normalizer used for testing.

Namespace

Drupal\serialization_test

Code

public function normalize($object, $format = NULL, array $context = []) : array {
  $normalized = (array) $object;
  // Add identifying value that can be used to verify that the expected
  // normalizer was invoked.
  $normalized['normalized_by'] = 'SerializationTestNormalizer';
  return $normalized;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.