Guides
Tutorials
Base item normalizer.
class ApiPlatform\Serializer\AbstractItemNormalizer extends Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer implements Symfony\Component\Serializer\Normalizer\NormalizerInterface, Symfony\Component\Serializer\Normalizer\DenormalizerInterface, Symfony\Component\Serializer\SerializerAwareInterface, Symfony\Component\Serializer\Normalizer\CacheableSupportsMethodInterface
{
public __construct(ApiPlatform\Metadata\Property\Factory\PropertyNameCollectionFactoryInterface $propertyNameCollectionFactory, ApiPlatform\Metadata\Property\Factory\PropertyMetadataFactoryInterface $propertyMetadataFactory, ApiPlatform\Api\IriConverterInterface $iriConverter, ApiPlatform\Api\ResourceClassResolverInterface $resourceClassResolver, null|Symfony\Component\PropertyAccess\PropertyAccessorInterface $propertyAccessor, null|Symfony\Component\Serializer\NameConverter\NameConverterInterface $nameConverter, null|Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface $classMetadataFactory, array $defaultContext, null|ApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface $resourceMetadataCollectionFactory, null|ApiPlatform\Symfony\Security\ResourceAccessCheckerInterface $resourceAccessChecker)
public supportsNormalization($data, null|string $format, array $context): bool
public hasCacheableSupportsMethod(): bool
public normalize($object, null|string $format, array $context): ArrayObject|array|string|int|float|bool
public supportsDenormalization($data, string $type, null|string $format, array $context): bool
public denormalize($data, string $class, null|string $format, array $context)
protected instantiateObject(array $data, string $class, array $context, ReflectionClass $reflectionClass, array|bool $allowedAttributes, null|string $format): object
protected getClassDiscriminatorResolvedClass(array $data, string $class, array $context): string
protected createConstructorArgument($parameterData, string $key, ReflectionParameter $constructorParameter, array $context, null|string $format)
protected extractAttributes($object, $format, array $context): array<int, string>
protected getAllowedAttributes(object|string $classOrObject, array $context, bool $attributesAsString): array|bool
protected isAllowedAttribute(object|string $classOrObject, string $attribute, null|string $format, array $context): bool
protected canAccessAttribute(null|object $object, string $attribute, array $context): bool
protected canAccessAttributePostDenormalize(null|object $object, null|object $previousObject, string $attribute, array $context): bool
protected setAttributeValue(object $object, string $attribute, $value, null|string $format, array $context): null
protected validateType(string $attribute, Symfony\Component\PropertyInfo\Type $type, $value, null|string $format, array $context): null
protected denormalizeCollection(string $attribute, ApiPlatform\Metadata\ApiProperty $propertyMetadata, Symfony\Component\PropertyInfo\Type $type, string $className, $value, null|string $format, array $context): array
protected denormalizeRelation(string $attributeName, ApiPlatform\Metadata\ApiProperty $propertyMetadata, string $className, $value, null|string $format, array $context): object
protected getFactoryOptions(array $context): array
protected getAttributeValue(object $object, string $attribute, null|string $format, array $context)
protected normalizeCollectionOfRelations(ApiPlatform\Metadata\ApiProperty $propertyMetadata, iterable $attributeValue, string $resourceClass, null|string $format, array $context): array
protected normalizeRelation(ApiPlatform\Metadata\ApiProperty $propertyMetadata, null|object $relatedObject, string $resourceClass, null|string $format, array $context): ArrayObject|array|string
protected getAttributes(object $object, null|string $format, array $context): array<int, string>
protected denormalizeParameter(ReflectionClass $class, ReflectionParameter $parameter, string $parameterName, $parameterData, array $context, null|string $format)
protected createChildContext(array $parentContext, string $attribute, null|string $format): array
protected isCircularReference(object $object, array $context): bool
protected handleCircularReference(object $object, null|string $format, array $context)
protected getGroups(array $context): array
protected prepareForDenormalization($data): array
protected getConstructor(array $data, string $class, array $context, ReflectionClass $reflectionClass, array|bool $allowedAttributes): ReflectionMethod
protected validateCallbackContext(array $context, string $contextType): null
protected applyCallbacks($value, object|string $object, string $attribute, null|string $format, array $context)
protected getAttributeNormalizationContext(object $object, string $attribute, array $context): array
protected getAttributeDenormalizationContext(string $class, string $attribute, array $context): array
protected getAttributeMetadata(object|string $objectOrClass, string $attribute): Symfony\Component\Serializer\Mapping\AttributeMetadataInterface
protected extractObjectToPopulate(string $class, array $context, null|string $key): object
public setSerializer(Symfony\Component\Serializer\SerializerInterface $serializer)
protected getInputClass(array $context): string
protected getOutputClass(array $context): string
}class ApiPlatform\Serializer\AbstractItemNormalizer extends Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer implements Symfony\Component\Serializer\Normalizer\NormalizerInterface, Symfony\Component\Serializer\Normalizer\DenormalizerInterface, Symfony\Component\Serializer\SerializerAwareInterface, Symfony\Component\Serializer\Normalizer\CacheableSupportsMethodInterface
{
public __construct(ApiPlatform\Metadata\Property\Factory\PropertyNameCollectionFactoryInterface $propertyNameCollectionFactory, ApiPlatform\Metadata\Property\Factory\PropertyMetadataFactoryInterface $propertyMetadataFactory, ApiPlatform\Api\IriConverterInterface $iriConverter, ApiPlatform\Api\ResourceClassResolverInterface $resourceClassResolver, null|Symfony\Component\PropertyAccess\PropertyAccessorInterface $propertyAccessor, null|Symfony\Component\Serializer\NameConverter\NameConverterInterface $nameConverter, null|Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface $classMetadataFactory, array $defaultContext, null|ApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface $resourceMetadataCollectionFactory, null|ApiPlatform\Symfony\Security\ResourceAccessCheckerInterface $resourceAccessChecker)
public supportsNormalization($data, null|string $format, array $context): bool
public hasCacheableSupportsMethod(): bool
public normalize($object, null|string $format, array $context): ArrayObject|array|string|int|float|bool
public supportsDenormalization($data, string $type, null|string $format, array $context): bool
public denormalize($data, string $class, null|string $format, array $context)
protected instantiateObject(array $data, string $class, array $context, ReflectionClass $reflectionClass, array|bool $allowedAttributes, null|string $format): object
protected getClassDiscriminatorResolvedClass(array $data, string $class, array $context): string
protected createConstructorArgument($parameterData, string $key, ReflectionParameter $constructorParameter, array $context, null|string $format)
protected extractAttributes($object, $format, array $context): array<int, string>
protected getAllowedAttributes(object|string $classOrObject, array $context, bool $attributesAsString): array|bool
protected isAllowedAttribute(object|string $classOrObject, string $attribute, null|string $format, array $context): bool
protected canAccessAttribute(null|object $object, string $attribute, array $context): bool
protected canAccessAttributePostDenormalize(null|object $object, null|object $previousObject, string $attribute, array $context): bool
protected setAttributeValue(object $object, string $attribute, $value, null|string $format, array $context): null
protected validateType(string $attribute, Symfony\Component\PropertyInfo\Type $type, $value, null|string $format, array $context): null
protected denormalizeCollection(string $attribute, ApiPlatform\Metadata\ApiProperty $propertyMetadata, Symfony\Component\PropertyInfo\Type $type, string $className, $value, null|string $format, array $context): array
protected denormalizeRelation(string $attributeName, ApiPlatform\Metadata\ApiProperty $propertyMetadata, string $className, $value, null|string $format, array $context): object
protected getFactoryOptions(array $context): array
protected getAttributeValue(object $object, string $attribute, null|string $format, array $context)
protected normalizeCollectionOfRelations(ApiPlatform\Metadata\ApiProperty $propertyMetadata, iterable $attributeValue, string $resourceClass, null|string $format, array $context): array
protected normalizeRelation(ApiPlatform\Metadata\ApiProperty $propertyMetadata, null|object $relatedObject, string $resourceClass, null|string $format, array $context): ArrayObject|array|string
protected getAttributes(object $object, null|string $format, array $context): array<int, string>
protected denormalizeParameter(ReflectionClass $class, ReflectionParameter $parameter, string $parameterName, $parameterData, array $context, null|string $format)
protected createChildContext(array $parentContext, string $attribute, null|string $format): array
protected isCircularReference(object $object, array $context): bool
protected handleCircularReference(object $object, null|string $format, array $context)
protected getGroups(array $context): array
protected prepareForDenormalization($data): array
protected getConstructor(array $data, string $class, array $context, ReflectionClass $reflectionClass, array|bool $allowedAttributes): ReflectionMethod
protected validateCallbackContext(array $context, string $contextType): null
protected applyCallbacks($value, object|string $object, string $attribute, null|string $format, array $context)
protected getAttributeNormalizationContext(object $object, string $attribute, array $context): array
protected getAttributeDenormalizationContext(string $class, string $attribute, array $context): array
protected getAttributeMetadata(object|string $objectOrClass, string $attribute): Symfony\Component\Serializer\Mapping\AttributeMetadataInterface
protected extractObjectToPopulate(string $class, array $context, null|string $key): object
public setSerializer(Symfony\Component\Serializer\SerializerInterface $serializer)
protected getInputClass(array $context): string
protected getOutputClass(array $context): string
}Symfony\Component\PropertyAccess\PropertyAccessorInterface $propertyAccessorSymfony\Component\PropertyAccess\PropertyAccessorInterface $propertyAccessorarray $localCachearray $localCachearray $localFactoryOptionsCachearray $localFactoryOptionsCacheApiPlatform\Metadata\Property\Factory\PropertyNameCollectionFactoryInterface $propertyNameCollectionFactoryApiPlatform\Metadata\Property\Factory\PropertyNameCollectionFactoryInterface $propertyNameCollectionFactoryApiPlatform\Metadata\Property\Factory\PropertyMetadataFactoryInterface $propertyMetadataFactoryApiPlatform\Metadata\Property\Factory\PropertyMetadataFactoryInterface $propertyMetadataFactoryApiPlatform\Api\IriConverterInterface $iriConverterApiPlatform\Api\IriConverterInterface $iriConverterApiPlatform\Api\ResourceClassResolverInterface $resourceClassResolverApiPlatform\Api\ResourceClassResolverInterface $resourceClassResolverApiPlatform\Symfony\Security\ResourceAccessCheckerInterface $resourceAccessCheckerApiPlatform\Symfony\Security\ResourceAccessCheckerInterface $resourceAccessCheckerSymfony\Component\Serializer\Mapping\ClassDiscriminatorResolverInterface $classDiscriminatorResolverSymfony\Component\Serializer\Mapping\ClassDiscriminatorResolverInterface $classDiscriminatorResolver$defaultContext$defaultContextSymfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface $classMetadataFactorySymfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface $classMetadataFactorySymfony\Component\Serializer\NameConverter\NameConverterInterface $nameConverterSymfony\Component\Serializer\NameConverter\NameConverterInterface $nameConverterSymfony\Component\Serializer\Normalizer\SerializerInterface $serializerSymfony\Component\Serializer\Normalizer\SerializerInterface $serializerApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface $resourceMetadataCollectionFactoryApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface $resourceMetadataCollectionFactorypublic __construct(ApiPlatform\Metadata\Property\Factory\PropertyNameCollectionFactoryInterface $propertyNameCollectionFactory, ApiPlatform\Metadata\Property\Factory\PropertyMetadataFactoryInterface $propertyMetadataFactory, ApiPlatform\Api\IriConverterInterface $iriConverter, ApiPlatform\Api\ResourceClassResolverInterface $resourceClassResolver, null|Symfony\Component\PropertyAccess\PropertyAccessorInterface $propertyAccessor, null|Symfony\Component\Serializer\NameConverter\NameConverterInterface $nameConverter, null|Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface $classMetadataFactory, array $defaultContext, null|ApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface $resourceMetadataCollectionFactory, null|ApiPlatform\Symfony\Security\ResourceAccessCheckerInterface $resourceAccessChecker)public __construct(ApiPlatform\Metadata\Property\Factory\PropertyNameCollectionFactoryInterface $propertyNameCollectionFactory, ApiPlatform\Metadata\Property\Factory\PropertyMetadataFactoryInterface $propertyMetadataFactory, ApiPlatform\Api\IriConverterInterface $iriConverter, ApiPlatform\Api\ResourceClassResolverInterface $resourceClassResolver, null|Symfony\Component\PropertyAccess\PropertyAccessorInterface $propertyAccessor, null|Symfony\Component\Serializer\NameConverter\NameConverterInterface $nameConverter, null|Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface $classMetadataFactory, array $defaultContext, null|ApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface $resourceMetadataCollectionFactory, null|ApiPlatform\Symfony\Security\ResourceAccessCheckerInterface $resourceAccessChecker)| propertyNameCollectionFactory | ApiPlatform\Metadata\Property\Factory\PropertyNameCollectionFactoryInterface | |
| propertyMetadataFactory | ApiPlatform\Metadata\Property\Factory\PropertyMetadataFactoryInterface | |
| iriConverter | ApiPlatform\Api\IriConverterInterface | |
| resourceClassResolver | ApiPlatform\Api\ResourceClassResolverInterface | |
| propertyAccessor | Symfony\Component\PropertyAccess\PropertyAccessorInterface | |
| nameConverter | Symfony\Component\Serializer\NameConverter\NameConverterInterface | |
| classMetadataFactory | Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface | |
| defaultContext | array | |
| resourceMetadataCollectionFactory | ApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface | |
| resourceAccessChecker | ApiPlatform\Symfony\Security\ResourceAccessCheckerInterface |
Checks whether the given class is supported for normalization by this normalizer.
public supportsNormalization($data, null|string $format, array $context): boolpublic supportsNormalization($data, null|string $format, array $context): bool| data | ||
| format | string | |
| context | array |
bool
public hasCacheableSupportsMethod(): boolpublic hasCacheableSupportsMethod(): boolbool
Normalizes an object into a set of arrays/scalars.
public normalize($object, null|string $format, array $context): ArrayObject|array|string|int|float|boolpublic normalize($object, null|string $format, array $context): ArrayObject|array|string|int|float|bool| object | ||
| format | string | |
| context | array |
ArrayObject
array
string
int
float
bool
Checks whether the given class is supported for denormalization by this normalizer.
public supportsDenormalization($data, string $type, null|string $format, array $context): boolpublic supportsDenormalization($data, string $type, null|string $format, array $context): bool| data | ||
| type | string | |
| format | string | |
| context | array |
bool
Denormalizes data back into an object of the given class.
public denormalize($data, string $class, null|string $format, array $context)public denormalize($data, string $class, null|string $format, array $context)| data | ||
| class | string | |
| format | string | |
| context | array |
Method copy-pasted from symfony/serializer. Remove it after symfony/serializer version update @see https://github.com/symfony/symfony/pull/28263.
protected instantiateObject(array $data, string $class, array $context, ReflectionClass $reflectionClass, array|bool $allowedAttributes, null|string $format): objectprotected instantiateObject(array $data, string $class, array $context, ReflectionClass $reflectionClass, array|bool $allowedAttributes, null|string $format): object| data | array | |
| class | string | |
| context | array | |
| reflectionClass | ReflectionClass | |
| allowedAttributes | array bool | |
| format | string |
object
protected getClassDiscriminatorResolvedClass(array $data, string $class, array $context): stringprotected getClassDiscriminatorResolvedClass(array $data, string $class, array $context): string| data | array | |
| class | string | |
| context | array |
string
protected createConstructorArgument($parameterData, string $key, ReflectionParameter $constructorParameter, array $context, null|string $format)protected createConstructorArgument($parameterData, string $key, ReflectionParameter $constructorParameter, array $context, null|string $format)| parameterData | ||
| key | string | |
| constructorParameter | ReflectionParameter | |
| context | array | |
| format | string |
Extracts attributes to normalize from the class of the given object, format and context.Unused in this context.
protected extractAttributes($object, $format, array $context): array<int, string>protected extractAttributes($object, $format, array $context): array<int, string>| object | ||
| format | ||
| context | array |
array<int, string>
Gets attributes to normalize using groups.
protected getAllowedAttributes(object|string $classOrObject, array $context, bool $attributesAsString): array|boolprotected getAllowedAttributes(object|string $classOrObject, array $context, bool $attributesAsString): array|bool| classOrObject | object string | |
| context | array | |
| attributesAsString | bool |
array
bool
Is this attribute allowed?
protected isAllowedAttribute(object|string $classOrObject, string $attribute, null|string $format, array $context): boolprotected isAllowedAttribute(object|string $classOrObject, string $attribute, null|string $format, array $context): bool| classOrObject | object string | |
| attribute | string | |
| format | string | |
| context | array |
bool
Check if access to the attribute is granted.
protected canAccessAttribute(null|object $object, string $attribute, array $context): boolprotected canAccessAttribute(null|object $object, string $attribute, array $context): bool| object | object | |
| attribute | string | |
| context | array |
bool
Check if access to the attribute is granted.
protected canAccessAttributePostDenormalize(null|object $object, null|object $previousObject, string $attribute, array $context): boolprotected canAccessAttributePostDenormalize(null|object $object, null|object $previousObject, string $attribute, array $context): bool| object | object | |
| previousObject | object | |
| attribute | string | |
| context | array |
bool
Sets attribute value.
protected setAttributeValue(object $object, string $attribute, $value, null|string $format, array $context): nullprotected setAttributeValue(object $object, string $attribute, $value, null|string $format, array $context): null| object | object | |
| attribute | string | |
| value | ||
| format | string | |
| context | array |
null
Validates the type of the value. Allows using integers as floats for JSON formats.
protected validateType(string $attribute, Symfony\Component\PropertyInfo\Type $type, $value, null|string $format, array $context): nullprotected validateType(string $attribute, Symfony\Component\PropertyInfo\Type $type, $value, null|string $format, array $context): null| attribute | string | |
| type | Symfony\Component\PropertyInfo\Type | |
| value | ||
| format | string | |
| context | array |
null
Denormalizes a collection of objects.
protected denormalizeCollection(string $attribute, ApiPlatform\Metadata\ApiProperty $propertyMetadata, Symfony\Component\PropertyInfo\Type $type, string $className, $value, null|string $format, array $context): arrayprotected denormalizeCollection(string $attribute, ApiPlatform\Metadata\ApiProperty $propertyMetadata, Symfony\Component\PropertyInfo\Type $type, string $className, $value, null|string $format, array $context): array| attribute | string | |
| propertyMetadata | ApiPlatform\Metadata\ApiProperty | |
| type | Symfony\Component\PropertyInfo\Type | |
| className | string | |
| value | ||
| format | string | |
| context | array |
array
Denormalizes a relation.
protected denormalizeRelation(string $attributeName, ApiPlatform\Metadata\ApiProperty $propertyMetadata, string $className, $value, null|string $format, array $context): objectprotected denormalizeRelation(string $attributeName, ApiPlatform\Metadata\ApiProperty $propertyMetadata, string $className, $value, null|string $format, array $context): object| attributeName | string | |
| propertyMetadata | ApiPlatform\Metadata\ApiProperty | |
| className | string | |
| value | ||
| format | string | |
| context | array |
object
Gets the options for the property name collection / property metadata factories.
protected getFactoryOptions(array $context): arrayprotected getFactoryOptions(array $context): array| context | array |
array
Gets the attribute value.
protected getAttributeValue(object $object, string $attribute, null|string $format, array $context)protected getAttributeValue(object $object, string $attribute, null|string $format, array $context)| object | object | |
| attribute | string | |
| format | string | |
| context | array |
Normalizes a collection of relations (to-many).
protected normalizeCollectionOfRelations(ApiPlatform\Metadata\ApiProperty $propertyMetadata, iterable $attributeValue, string $resourceClass, null|string $format, array $context): arrayprotected normalizeCollectionOfRelations(ApiPlatform\Metadata\ApiProperty $propertyMetadata, iterable $attributeValue, string $resourceClass, null|string $format, array $context): array| propertyMetadata | ApiPlatform\Metadata\ApiProperty | |
| attributeValue | iterable | |
| resourceClass | string | |
| format | string | |
| context | array |
array
Normalizes a relation.
protected normalizeRelation(ApiPlatform\Metadata\ApiProperty $propertyMetadata, null|object $relatedObject, string $resourceClass, null|string $format, array $context): ArrayObject|array|stringprotected normalizeRelation(ApiPlatform\Metadata\ApiProperty $propertyMetadata, null|object $relatedObject, string $resourceClass, null|string $format, array $context): ArrayObject|array|string| propertyMetadata | ApiPlatform\Metadata\ApiProperty | |
| relatedObject | object | |
| resourceClass | string | |
| format | string | |
| context | array |
ArrayObject
array
string
protected getInputClass(array $context): stringprotected getInputClass(array $context): string| context | array |
string
protected getOutputClass(array $context): stringprotected getOutputClass(array $context): string| context | array |
string