Base class for a normalizer dealing with objects.
- author Kévin Dunglas
Constants |
public Symfony Flag to tell the denormalizer to also populate existing objects on attributes of the main object. Setting this to true is only useful if you also specify the root object in OBJECT_TO_POPULATE. |
public Symfony How to track the current depth in the context. |
public Symfony While denormalizing, we can verify that type matches. You can disable this by setting this flag to true. |
public Symfony Set to true to respect the max depth metadata on fields. |
public Symfony Specify which context key are not relevant to determine which attributes of an object to (de)normalize. |
public Symfony Callback to allow to set a value for an attribute when the max depth has been reached. If no callback is given, the attribute is skipped. If a callable is given, its return value is used (even if null). The arguments are:
|
public Symfony Flag to control whether an empty object should be kept as an object (in JSON: {}) or converted to a list (in JSON: []). |
public Symfony Flag to control whether fields with the value |
public Symfony Flag to control whether uninitialized PHP>=7.4 typed class properties should be excluded when normalizing. |
Methods |
public __construct(?Symfony |
public denormalize(?mixed $data, string $type, ?string $format = NULL, array $context = []) : ?mixed |
public normalize(?mixed $object, ?string $format = NULL, array $context = []) : ArrayObject|array|string|int|float|bool|?null |
public supportsDenormalization(?mixed $data, string $type, ?string $format = NULL, array $context = []) : bool |
public supportsNormalization(?mixed $data, ?string $format = NULL, array $context = []) : bool |
Constants |
Properties |
protected ?Symfony |
Methods |
protected createChildContext(array $parentContext, string $attribute, ?string $format) : array Overwritten to update the cache key for the child. We must not mix up the attribute cache between parent and children.
|
protected denormalizeParameter(ReflectionClass $class, ReflectionParameter $parameter, string $parameterName, ?mixed $parameterData, array $context, ?string $format = NULL) : ?mixed
|
protected abstract extractAttributes(object $object, ?string $format = NULL, array $context = []) : array Extracts attributes to normalize from the class of the given object, format and context.
|
protected getAttributes(object $object, ?string $format, array $context) : array Gets and caches attributes for the given object, format and context.
|
protected abstract getAttributeValue(object $object, string $attribute, ?string $format = NULL, array $context = []) : ?mixed Gets the attribute value. |
protected instantiateObject(array $data, string $class, array $context, ReflectionClass $reflectionClass, array|bool $allowedAttributes, ?string $format = NULL) : object |
protected abstract setAttributeValue(object $object, string $attribute, ?mixed $value, ?string $format = NULL, array $context = []) : void |
Properties |
private array $attributesCache = [] |
private readonly Closure $objectClassResolver |
private ?Symfony |
private array $typeCache = []
|
Methods |
private getCacheKey(?string $format, array $context) : string|bool Builds the cache key for the attributes cache. The key must be different for every option in the context that could change which attributes should be handled. |
private getMappedClass(array $data, string $class, array $context) : string
|
private getNestedAttributes(string $class) : array Returns all attributes with a SerializedPath attribute and the respective path. |
private getPropertyType(string $className, string $property) : Symfony BC layer for PropertyTypeExtractorInterface::getTypes(). Can be removed as soon as PropertyTypeExtractorInterface::getTypes() is removed (8.0).
|
private getType(string $currentClass, string $attribute) : Symfony
|
private isMaxDepthReached(array $attributesMetadata, string $class, string $attribute, array $context) : bool Is the max depth reached for the given attribute?
|
private isUninitializedValueError(Error|Symfony This error may occur when specific object normalizer implementation gets attribute value by accessing a public uninitialized property or by calling a method accessing such property. |
private removeNestedValue(array $path, array $data) : array |
private updateData(array $data, string $attribute, ?mixed $attributeValue, string $class, ?string $format, array $context, ?array $attributesMetadata, ?Symfony Sets an attribute and apply the name converter if necessary. |
private validateAndDenormalize(Symfony Validates the submitted data and denormalizes it.
|
private validateAndDenormalizeLegacy(array $types, string $currentClass, string $attribute, ?mixed $data, ?string $format, array $context) : ?mixed Validates the submitted data and denormalizes it. BC layer for PropertyTypeExtractorInterface::getTypes(). Can be removed as soon as PropertyTypeExtractorInterface::getTypes() is removed (8.0).
|