References AbstractCollectionNormalizer
Reference
C
Class

ApiPlatform\Serializer\AbstractCollectionNormalizer

Base collection normalizer.

class ApiPlatform\Serializer\AbstractCollectionNormalizer implements Symfony\Component\Serializer\Normalizer\NormalizerInterface, Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface, ApiPlatform\Serializer\CacheableSupportsMethodInterface
{
    public __construct(|`<a href="/docs/main/references/Api/ResourceClassResolverInterface">ApiPlatform\Api\ResourceClassResolverInterface</a>` $resourceClassResolver, string $pageParameterName, null|`<a href="/docs/main/references/Metadata/Resource/Factory/ResourceMetadataCollectionFactoryInterface">ApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface $resourceMetadataFactory)
    public supportsNormalization($data, null|string $format, array $context): bool
    public hasCacheableSupportsMethod(): bool
    public getSupportedTypes(null|string $format): array
    public normalize(null|iterable $object, null|string $format, array $context): ArrayObject|array|string|int|float|bool
    protected normalizeRawCollection(iterable $object, null|string $format, array $context): ArrayObject|array
    protected getPaginationConfig(iterable $object, array $context): array
    protected getOperation(array $context): ApiPlatform\Metadata\Operation
    protected getPaginationData(iterable $object, array $context): array
    protected getItemsData(iterable $object, null|string $format, array $context): array
    protected initContext(string $resourceClass, array $context): array
    public setNormalizer(Symfony\Component\Serializer\Normalizer\NormalizerInterface $normalizer): null
    protected createOperationContext(array $context, null|string $resourceClass): array
}

Properties

resourceClassResolver

pageParameterName

string $pageParameterName

resourceMetadataFactory

normalizer

Symfony\Component\Serializer\Normalizer\NormalizerInterface $normalizer

Methods

__construct

Parameters

resourceClassResolver`ApiPlatform\Metadata\ResourceClassResolverInterface`
`ApiPlatform\Api\ResourceClassResolverInterface`
pageParameterNamestring
resourceMetadataFactory`ApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface`

supportsNormalization

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

public supportsNormalization($data, null|string $format, array $context): bool

Parameters

data
formatstring
contextarray

Returns

bool

hasCacheableSupportsMethod

public hasCacheableSupportsMethod(): bool

Returns

bool

getSupportedTypes

public getSupportedTypes(null|string $format): array

Parameters

formatstring

Returns

array

normalize

Normalizes an object into a set of arrays/scalars.

public normalize(null|iterable $object, null|string $format, array $context): ArrayObject|array|string|int|float|bool

Parameters

objectiterable
formatstring
contextarray

Returns

ArrayObject
array
string
int
float
bool

normalizeRawCollection

Normalizes a raw collection (not API resources).

protected normalizeRawCollection(iterable $object, null|string $format, array $context): ArrayObject|array

Parameters

objectiterable
formatstring
contextarray

Returns

ArrayObject
array

getPaginationConfig

Gets the pagination configuration.

protected getPaginationConfig(iterable $object, array $context): array

Parameters

objectiterable
contextarray

Returns

array

getOperation

protected getOperation(array $context): ApiPlatform\Metadata\Operation

Parameters

contextarray

Returns

<a href="/docs/main/references/Metadata/Operation">ApiPlatform\Metadata\Operation</a>

getPaginationData

Gets the pagination data.

protected getPaginationData(iterable $object, array $context): array

Parameters

objectiterable
contextarray

Returns

array

getItemsData

Gets items data.

protected getItemsData(iterable $object, null|string $format, array $context): array

Parameters

objectiterable
formatstring
contextarray

Returns

array

initContext

Initializes the context.

protected initContext(string $resourceClass, array $context): array

Parameters

resourceClassstring
contextarray

Returns

array

setNormalizer

public setNormalizer(Symfony\Component\Serializer\Normalizer\NormalizerInterface $normalizer): null

Parameters

normalizerSymfony\Component\Serializer\Normalizer\NormalizerInterface

Returns

null

createOperationContext

This context is created when working on a relation context or items of a collection. It cleans the previously given context as the operation changes.

protected createOperationContext(array $context, null|string $resourceClass): array

Parameters

contextarray
resourceClassstring

Returns

array

Made with love by

Les-Tilleuls.coop can help you design and develop your APIs and web projects, and train your teams in API Platform, Symfony, Next.js, Kubernetes and a wide range of other technologies.

Learn more

Copyright © 2023 Kévin Dunglas

Sponsored by Les-Tilleuls.coop