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 Setting this to true is only useful if you also specify the root object |
public Symfony How to track the current depth in the context. |
public Symfony While denormalizing, we can verify that types match. 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 |
public Symfony Callback to allow to set a value for an attribute when the max depth has If no callback is given, the attribute is skipped. If a callable is The arguments are:
|
public Symfony Flag to control whether an empty object should be kept as an object (in |
public Symfony Flag to control whether fields with the value |
public Symfony Flag to control whether uninitialized PHP>=7.4 typed class properties |
Methods |
public __construct(?Symfony |
public denormalize(?mixed $data, string $type, ?string $format = NULL, array $context = [])
|
public normalize(?mixed $object, ?string $format = NULL, array $context = [])
|
public supportsDenormalization(?mixed $data, string $type, ?string $format = NULL)
|
public supportsNormalization(?mixed $data, ?string $format = NULL)
|
Constants |
Properties |
protected $classDiscriminatorResolver = NULL
|
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 = []) 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 = []) Gets the attribute value.
|
protected instantiateObject(array $data, string $class, array $context, ReflectionClass $reflectionClass, array|bool $allowedAttributes, ?string $format = NULL)
|
protected abstract setAttributeValue(object $object, string $attribute, ?mixed $value, ?string $format = NULL, array $context = [])
|
Properties |
private array $attributesCache = [] |
privatereadonly Closure $objectClassResolver |
private ?Symfony |
private array $typesCache = [] |
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 annotation and the respective path. |
private getTypes(string $currentClass, string $attribute) : ?array
|
private isMaxDepthReached(array $attributesMetadata, string $class, string $attribute, array $context) : bool Is the max depth reached for the given attribute?
|
private isUninitializedValueError(Error $e) : bool This error may occur when specific object normalizer implementation gets attribute value |
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(array $types, string $currentClass, string $attribute, ?mixed $data, ?string $format, array $context) : ?mixed Validates the submitted data and denormalizes it.
|