Copied!

A normalizer that uses an objects own JsonSerializable implementation.

Cloneable Instantiable
Constants
public Symfony\Component\Serializer\Normalizer\AbstractNormalizer ::ALLOW_EXTRA_ATTRIBUTES = 'allow_extra_attributes'
 

If ATTRIBUTES are specified, and the source has fields that are not part of that list,
either ignore those attributes (true) or throw an ExtraAttributesException (false).

public Symfony\Component\Serializer\Normalizer\AbstractNormalizer ::ATTRIBUTES = 'attributes'
 

Limit (de)normalize to the specified names.

For nested structures, this list needs to reflect the object tree.

public Symfony\Component\Serializer\Normalizer\AbstractNormalizer ::CALLBACKS = 'callbacks'
 

Hashmap of field name => callable to (de)normalize this field.

The callable is called if the field is encountered with the arguments:

  • mixed $attributeValue value of this field
  • object|string $object the whole object being normalized or the object's class being denormalized
  • string $attributeName name of the attribute being (de)normalized
  • string $format the requested format
  • array $context the serialization context
public Symfony\Component\Serializer\Normalizer\AbstractNormalizer ::CIRCULAR_REFERENCE_HANDLER = 'circular_reference_handler'
 

Handler to call when a circular reference has been detected.

If you specify no handler, a CircularReferenceException is thrown.

The method will be called with ($object, $format, $context) and its
return value is returned as the result of the normalize call.

public Symfony\Component\Serializer\Normalizer\AbstractNormalizer ::CIRCULAR_REFERENCE_LIMIT = 'circular_reference_limit'
 

How many loops of circular reference to allow while normalizing.

The default value of 1 means that when we encounter the same object a
second time, we consider that a circular reference.

You can raise this value for special cases, e.g. in combination with the
max depth setting of the object normalizer.

public Symfony\Component\Serializer\Normalizer\DenormalizerInterface ::COLLECT_DENORMALIZATION_ERRORS = 'collect_denormalization_errors'
public Symfony\Component\Serializer\Normalizer\AbstractNormalizer ::DEFAULT_CONSTRUCTOR_ARGUMENTS = 'default_constructor_arguments'
 

Hashmap of default values for constructor arguments.

The names need to match the parameter names in the constructor arguments.

public Symfony\Component\Serializer\Normalizer\AbstractNormalizer ::GROUPS = 'groups'
 

Only (de)normalize attributes that are in the specified groups.

public Symfony\Component\Serializer\Normalizer\AbstractNormalizer ::IGNORED_ATTRIBUTES = 'ignored_attributes'
 

Skip the specified attributes when normalizing an object tree.

This list is applied to each element of nested structures.

Note: The behaviour for nested structures is different from ATTRIBUTES
for historical reason. Aligning the behaviour would be a BC break.

public Symfony\Component\Serializer\Normalizer\AbstractNormalizer ::OBJECT_TO_POPULATE = 'object_to_populate'
 

Instead of creating a new instance of an object, update the specified object.

If you have a nested structure, child objects will be overwritten with
new instances unless you set DEEP_OBJECT_TO_POPULATE to true.

Methods
public Symfony\Component\Serializer\Normalizer\AbstractNormalizer :: __construct ( ? Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface $classMetadataFactory = NULL , ? Symfony\Component\Serializer\NameConverter\NameConverterInterface $nameConverter = NULL , array $defaultContext = [ ] )
 

Sets the {@link ClassMetadataFactoryInterface} to use.

public denormalize ( ? mixed $data , string $type , ? string $format = NULL , array $context = [ ] ) : ? mixed
 

Denormalizes data back into an object of the given class.

  • param mixed $data Data to restore
  • param string $type The expected class to instantiate
  • param string $format Format the given data was extracted from
  • param array $context Options available to the denormalizer
  • return mixed
  • throws BadMethodCallException Occurs when the normalizer is not called in an expected context
  • throws InvalidArgumentException Occurs when the arguments are not coherent or not supported
  • throws UnexpectedValueException Occurs when the item cannot be hydrated with the given data
  • throws ExtraAttributesException Occurs when the item doesn't have attribute to receive given data
  • throws LogicException Occurs when the normalizer is not supposed to denormalize
  • throws RuntimeException Occurs if the class cannot be instantiated
  • throws ExceptionInterface Occurs for all the other cases of errors
public hasCacheableSupportsMethod () : bool
 
public normalize ( ? mixed $object , ? string $format = NULL , array $context = [ ] ) : ArrayObject | array | string | int | float | bool | null
 

Normalizes an object into a set of arrays/scalars.

  • param mixed $object Object to normalize
  • param string $format Format the normalization result will be encoded as
  • param array $context Context options for the normalizer
  • return array | string | int | float | bool | ArrayObject | null \ArrayObject is used to make sure an empty object is encoded as an object not an array
  • throws InvalidArgumentException Occurs when the object given is not a supported type for the normalizer
  • throws CircularReferenceException Occurs when the normalizer detects a circular reference when no circular
    reference handler can fix it
  • throws LogicException Occurs when the normalizer is not called in an expected context
  • throws ExceptionInterface Occurs for all the other cases of errors
public Symfony\Component\Serializer\Normalizer\AbstractNormalizer :: setSerializer ( Symfony\Component\Serializer\SerializerInterface $serializer )
public supportsDenormalization ( ? mixed $data , string $type , ? string $format = NULL ) : bool
 

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

  • param mixed $data Data to denormalize from
  • param string $type The class to which the data should be denormalized
  • param string $format The format being deserialized from
  • param array $context Options available to the denormalizer
  • return bool
  • param array $context
public supportsNormalization ( ? mixed $data , ? string $format = NULL ) : bool
 

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

  • param mixed $data Data to normalize
  • param string $format The format being (de-)serialized from or into
  • param array $context Context options for the normalizer
  • return bool
  • param array $context
Constants
protected Symfony\Component\Serializer\Normalizer\AbstractNormalizer ::CIRCULAR_REFERENCE_LIMIT_COUNTERS = 'circular_reference_limit_counters'
 
  • internal
Properties
protected Symfony\Component\Serializer\Normalizer\AbstractNormalizer :: $classMetadataFactory
 
  • var ClassMetadataFactoryInterface | null
protected Symfony\Component\Serializer\Normalizer\AbstractNormalizer :: $defaultContext
protected Symfony\Component\Serializer\Normalizer\AbstractNormalizer :: $nameConverter
 
  • var NameConverterInterface | null
protected Symfony\Component\Serializer\Normalizer\AbstractNormalizer :: $serializer
 
  • var SerializerInterface
Methods
protected final Symfony\Component\Serializer\Normalizer\AbstractNormalizer :: applyCallbacks ( ? mixed $value , object | string $object , string $attribute , ? string $format , array $context ) : ? mixed
protected Symfony\Component\Serializer\Normalizer\AbstractNormalizer :: createChildContext ( array $parentContext , string $attribute , ? string $format ) : array
 
  • internal
protected Symfony\Component\Serializer\Normalizer\AbstractNormalizer :: denormalizeParameter ( ReflectionClass $class , ReflectionParameter $parameter , string $parameterName , ? mixed $parameterData , array $context , ? string $format = NULL ) : ? mixed
 
  • internal
protected Symfony\Component\Serializer\Normalizer\AbstractNormalizer :: extractObjectToPopulate ( string $class , array $context , ? string $key = NULL ) : ? object
 

Extract the object_to_populate field from the context if it exists
and is an instance of the provided $class.

  • param string $class The class the object should be
  • param string | null $key They in which to look for the object to populate.
    Keeps backwards compatibility with AbstractNormalizer.
protected Symfony\Component\Serializer\Normalizer\AbstractNormalizer :: getAllowedAttributes ( object | string $classOrObject , array $context , bool $attributesAsString = false )
 

Gets attributes to normalize using groups.

  • param bool $attributesAsString If false, return an array of {@link AttributeMetadataInterface}
  • throws LogicException if the 'allow_extra_attributes' context variable is false and no class metadata factory is provided
  • return string []| AttributeMetadataInterface []| bool
protected Symfony\Component\Serializer\Normalizer\AbstractNormalizer :: getConstructor ( array $data , string $class , array $context , ReflectionClass $reflectionClass , array | bool $allowedAttributes ) : ? ReflectionMethod
 

Returns the method to use to construct an object. This method must be either
the object constructor or static.

protected Symfony\Component\Serializer\Normalizer\AbstractNormalizer :: getGroups ( array $context ) : array
protected Symfony\Component\Serializer\Normalizer\AbstractNormalizer :: handleCircularReference ( object $object , ? string $format = NULL , array $context = [ ] ) : ? mixed
 

Handles a circular reference.

If a circular reference handler is set, it will be called. Otherwise, a
{@class CircularReferenceException} will be thrown.

  • final
  • throws CircularReferenceException
protected Symfony\Component\Serializer\Normalizer\AbstractNormalizer :: 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.

  • return object
  • throws RuntimeException
  • throws MissingConstructorArgumentsException
protected Symfony\Component\Serializer\Normalizer\AbstractNormalizer :: isAllowedAttribute ( object | string $classOrObject , string $attribute , ? string $format = NULL , array $context = [ ] )
 

Is this attribute allowed?

  • return bool
protected Symfony\Component\Serializer\Normalizer\AbstractNormalizer :: isCircularReference ( object $object , array $context ) : bool
 

Detects if the configured circular reference limit is reached.

  • throws CircularReferenceException
protected Symfony\Component\Serializer\Normalizer\AbstractNormalizer :: prepareForDenormalization ( ? mixed $data ) : array
 

Normalizes the given data to an array. It's particularly useful during
the denormalization process.

protected final Symfony\Component\Serializer\Normalizer\AbstractNormalizer :: validateCallbackContext ( array $context , string $contextType = '' ) : void
 

Validate callbacks set in context.

  • param string $contextType Used to specify which context is invalid in exceptions
  • throws InvalidArgumentException
© 2022 Bruce Wells
Search Namespaces \ Classes
Configuration