AbstractNormalizer
abstract class AbstractNormalizer implements NormalizerInterface, DenormalizerInterface, SerializerAwareInterface, CacheableSupportsMethodInterface
Normalizer implementation.
Traits
Constants
Properties
protected SerializerInterface | $serializer | from SerializerAwareTrait | |
protected | $defaultContext | ||
protected | $circularReferenceLimit | ||
protected callable|null | $circularReferenceHandler | ||
protected ClassMetadataFactoryInterface|null | $classMetadataFactory | ||
protected NameConverterInterface|null | $nameConverter | ||
protected | $callbacks | ||
protected | $ignoredAttributes | ||
protected | $camelizedAttributes |
Methods
Extract the object_to_populate
field from the context if it exists
and is an instance of the provided $class.
Sets the {@link ClassMetadataFactoryInterface} to use.
Sets circular reference handler.
Sets ignored attributes for normalization and denormalization.
No description
Detects if the configured circular reference limit is reached.
Handles a circular reference.
Gets attributes to normalize using groups.
Is this attribute allowed?
Normalizes the given data to an array. It's particularly useful during the denormalization process.
Returns the method to use to construct an object. This method must be either the object constructor or static.
Instantiates an object using constructor parameters when needed.
No description
No description
Details
protected object|null
extractObjectToPopulate(string $class, array $context, string $key = null)
Extract the object_to_populate
field from the context if it exists
and is an instance of the provided $class.
__construct(ClassMetadataFactoryInterface $classMetadataFactory = null, NameConverterInterface $nameConverter = null, array $defaultContext = array())
Sets the {@link ClassMetadataFactoryInterface} to use.
AbstractNormalizer
setCircularReferenceLimit(int $circularReferenceLimit)
deprecated
deprecated since Symfony 4.2
Sets circular reference limit.
AbstractNormalizer
setCircularReferenceHandler(callable $circularReferenceHandler)
deprecated
deprecated since Symfony 4.2
Sets circular reference handler.
AbstractNormalizer
setCallbacks(array $callbacks)
deprecated
deprecated since Symfony 4.2
Sets normalization callbacks.
AbstractNormalizer
setIgnoredAttributes(array $ignoredAttributes)
deprecated
deprecated since Symfony 4.2
Sets ignored attributes for normalization and denormalization.
protected bool
isCircularReference(object $object, array $context)
Detects if the configured circular reference limit is reached.
protected mixed
handleCircularReference($object)
Handles a circular reference.
If a circular reference handler is set, it will be called. Otherwise, a {@class CircularReferenceException} will be thrown.
protected string[]|AttributeMetadataInterface[]|bool
getAllowedAttributes(string|object $classOrObject, array $context, bool $attributesAsString = false)
Gets attributes to normalize using groups.
protected bool
isAllowedAttribute(object|string $classOrObject, string $attribute, string|null $format = null, array $context = array())
Is this attribute allowed?
protected array
prepareForDenormalization(object|array $data)
Normalizes the given data to an array. It's particularly useful during the denormalization process.
protected ReflectionMethod|null
getConstructor(array $data, string $class, array $context, ReflectionClass $reflectionClass, array|bool $allowedAttributes)
Returns the method to use to construct an object. This method must be either the object constructor or static.
protected object
instantiateObject(array $data, string $class, array $context, ReflectionClass $reflectionClass, array|bool $allowedAttributes, string $format = null)
Instantiates an object using constructor parameters when needed.
This method also allows to denormalize data into an existing object if it is present in the context with the object_to_populate. This object is removed from the context before being returned to avoid side effects when recursively normalizing an object graph.