function TimestampItemNormalizer::normalize

Same name and namespace in other branches
  1. 11.x core/modules/serialization/src/Normalizer/TimestampItemNormalizer.php \Drupal\serialization\Normalizer\TimestampItemNormalizer::normalize()
  2. 10 core/modules/serialization/src/Normalizer/TimestampItemNormalizer.php \Drupal\serialization\Normalizer\TimestampItemNormalizer::normalize()
  3. 9 core/modules/serialization/src/Normalizer/TimestampItemNormalizer.php \Drupal\serialization\Normalizer\TimestampItemNormalizer::normalize()
  4. 8.9.x core/modules/serialization/src/Normalizer/TimestampItemNormalizer.php \Drupal\serialization\Normalizer\TimestampItemNormalizer::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.

Overrides ComplexDataNormalizer::normalize

File

core/modules/serialization/src/Normalizer/TimestampItemNormalizer.php, line 34

Class

TimestampItemNormalizer
Converts values for TimestampItem to and from common formats.

Namespace

Drupal\serialization\Normalizer

Code

public function normalize($object, $format = NULL, array $context = []) : array {
  return parent::normalize($object, $format, $context) + [
    // 'format' is not a property on Timestamp objects. This is present to
    // assist consumers of this data.
'format' => \DateTime::RFC3339,
  ];
}

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