Documentation

CustomNormalizer
in package
implements NormalizerInterface, DenormalizerInterface, SerializerAwareInterface, CacheableSupportsMethodInterface Uses ObjectToPopulateTrait, SerializerAwareTrait

Tags
author

Jordi Boggiano j.boggiano@seld.be

Table of Contents

Interfaces

NormalizerInterface
DenormalizerInterface
SerializerAwareInterface
CacheableSupportsMethodInterface
Marker interface for normalizers and denormalizers that use only the type and the format in their supports*() methods.

Properties

$serializer  : SerializerInterface

Methods

denormalize()  : mixed
Denormalizes data back into an object of the given class.
hasCacheableSupportsMethod()  : bool
normalize()  : array<string|int, mixed>|string|int|float|bool|ArrayObject|null
Normalizes an object into a set of arrays/scalars.
setSerializer()  : mixed
supportsDenormalization()  : bool
Checks if the given class implements the DenormalizableInterface.
supportsNormalization()  : bool
Checks if the given class implements the NormalizableInterface.
extractObjectToPopulate()  : object|null
Extract the `object_to_populate` field from the context if it exists and is an instance of the provided $class.

Properties

Methods

denormalize()

Denormalizes data back into an object of the given class.

public denormalize(mixed $data, string $type[, string $format = null ][, array<string|int, mixed> $context = [] ]) : mixed
Parameters
$data : mixed

Data to restore

$type : string

The expected class to instantiate

$format : string = null

Format the given data was extracted from

$context : array<string|int, mixed> = []

Options available to the denormalizer

hasCacheableSupportsMethod()

public hasCacheableSupportsMethod() : bool
Return values
bool

normalize()

Normalizes an object into a set of arrays/scalars.

public normalize(mixed $object[, string $format = null ][, array<string|int, mixed> $context = [] ]) : array<string|int, mixed>|string|int|float|bool|ArrayObject|null
Parameters
$object : mixed

Object to normalize

$format : string = null

Format the normalization result will be encoded as

$context : array<string|int, mixed> = []

Context options for the normalizer

Return values
array<string|int, mixed>|string|int|float|bool|ArrayObject|null

\ArrayObject is used to make sure an empty object is encoded as an object not an array

supportsDenormalization()

Checks if the given class implements the DenormalizableInterface.

public supportsDenormalization(mixed $data, string $type[, string $format = null ]) : bool
Parameters
$data : mixed

Data to denormalize from

$type : string

The class to which the data should be denormalized

$format : string = null

The format being deserialized from

Return values
bool

supportsNormalization()

Checks if the given class implements the NormalizableInterface.

public supportsNormalization(mixed $data[, string $format = null ]) : bool
Parameters
$data : mixed

Data to normalize

$format : string = null

The format being (de-)serialized from or into

Return values
bool

extractObjectToPopulate()

Extract the `object_to_populate` field from the context if it exists and is an instance of the provided $class.

protected extractObjectToPopulate(string $class, array<string|int, mixed> $context[, string|null $key = null ]) : object|null
Parameters
$class : string

The class the object should be

$context : array<string|int, mixed>
$key : string|null = null

They in which to look for the object to populate. Keeps backwards compatibility with AbstractNormalizer.

Return values
object|null

        
On this page

Search results