class DateTimeNormalizer extends NormalizerBase implements DenormalizerInterface (View source)

internal  
 

Converts values for datetime objects to RFC3339 and from common formats.

Traits

SerializerAwareTrait

Properties

protected $supportedInterfaceOrClass {@inheritdoc}
protected string|string[] $format

List of formats which supports (de-)normalization.

from  NormalizerBase
protected string[] $allowedFormats

Allowed datetime formats for the denormalizer.

protected ImmutableConfig $systemDateConfig

The system's date configuration.

Methods

bool
supportsNormalization($data, $format = NULL)

{@inheritdoc}

supportsDenormalization($data, $type, $format = NULL)

Implements \Symfony\Component\Serializer\Normalizer\DenormalizerInterface::supportsDenormalization()

bool
checkFormat(string $format = NULL)

Checks if the provided format is supported by this normalizer.

addCacheableDependency(array $context, $data)

Adds cacheability if applicable.

bool
hasCacheableSupportsMethod()

{@inheritdoc}

__construct(ConfigFactoryInterface $config_factory)

Constructs a new DateTimeNormalizer instance.

array|string|int|float|bool|ArrayObject|null
normalize($datetime, $format = NULL, array $context = [])

{@inheritdoc}

getNormalizationTimezone()

Gets the timezone to be used during normalization.

mixed
denormalize($data, $class, $format = NULL, array $context = [])

{@inheritdoc}

Details

bool supportsNormalization($data, $format = NULL)

{@inheritdoc}

Parameters

$data
$format

Return Value

bool

supportsDenormalization($data, $type, $format = NULL)

Implements \Symfony\Component\Serializer\Normalizer\DenormalizerInterface::supportsDenormalization()

This class doesn't implement DenormalizerInterface, but most of its child classes do. Therefore, this method is implemented at this level to reduce code duplication.

Parameters

$data
$type
$format

protected bool checkFormat(string $format = NULL)

Checks if the provided format is supported by this normalizer.

Parameters

string $format

The format to check.

Return Value

bool

TRUE if the format is supported, FALSE otherwise. If no format is specified this will return TRUE.

protected addCacheableDependency(array $context, $data)

Adds cacheability if applicable.

Parameters

array $context

Context options for the normalizer.

$data

The data that might have cacheability information.

bool hasCacheableSupportsMethod()

{@inheritdoc}

Return Value

bool

__construct(ConfigFactoryInterface $config_factory)

Constructs a new DateTimeNormalizer instance.

Parameters

ConfigFactoryInterface $config_factory

A config factory for retrieving required config objects.

array|string|int|float|bool|ArrayObject|null normalize($datetime, $format = NULL, array $context = [])

{@inheritdoc}

Parameters

$datetime
$format
array $context

Return Value

array|string|int|float|bool|ArrayObject|null

protected getNormalizationTimezone()

Gets the timezone to be used during normalization.

See also

::normalize
DrupalDateTime::prepareTimezone

mixed denormalize($data, $class, $format = NULL, array $context = [])

{@inheritdoc}

Parameters

$data
$class
$format
array $context

Return Value

mixed