Documentation

ContextAwareNormalizerInterface extends NormalizerInterface

Adds the support of an extra $context parameter for the supportsNormalization method.

Tags
author

Kévin Dunglas dunglas@gmail.com

Table of Contents

Methods

normalize()  : array<string|int, mixed>|string|int|float|bool|ArrayObject|null
Normalizes an object into a set of arrays/scalars.
supportsNormalization()  : bool
Checks whether the given class is supported for normalization by this normalizer.

Methods

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

Tags
throws
InvalidArgumentException

Occurs when the object given is not a supported type for the normalizer

throws
CircularReferenceException

Occurs when the normalizer detects a circular reference when no circular reference handler can fix it

throws
LogicException

Occurs when the normalizer is not called in an expected context

throws
ExceptionInterface

Occurs for all the other cases of errors

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

supportsNormalization()

Checks whether the given class is supported for normalization by this normalizer.

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

Data to normalize

$format : string = null

The format being (de-)serialized from or into

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

options that normalizers have access to

Return values
bool

        
On this page

Search results