A normalizer that uses an objects own JsonSerializable implementation.
- author Fred Cox
Constants |
public Symfony 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 Limit (de)normalize to the specified names. For nested structures, this list needs to reflect the object tree. |
public Symfony Hashmap of field name => callable to (de)normalize this field. The callable is called if the field is encountered with the arguments:
|
public Symfony 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 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 |
public Symfony Hashmap of default values for constructor arguments. The names need to match the parameter names in the constructor arguments. |
public Symfony Flag to control whether a non-boolean value should be filtered using the filter_var function with the {@see https://www.php.net/manual/fr/filter.filters.validate.php} \FILTER_VALIDATE_BOOL filter before casting it to a boolean. "0", "false", "off", "no" and "" will be cast to false. "1", "true", "on" and "yes" will be cast to true. |
public Symfony Only (de)normalize attributes that are in the specified groups. |
public Symfony 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 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. |
public Symfony Require all properties to be listed in the input instead of falling back to null for nullable ones. |
Methods |
public Symfony\Component\Serializer\Normalizer\AbstractNormalizer::__construct(?Symfony Sets the {@link ClassMetadataFactoryInterface} to use. |
public denormalize(?mixed $data, string $type, ?string $format = NULL, array $context = []) : ?mixed |
public getSupportedTypes(?string $format) : array |
public normalize(?mixed $object, ?string $format = NULL, array $context = []) : ArrayObject|array|string|int|float|bool|?null |
public Symfony\Component\Serializer\Normalizer\AbstractNormalizer::setSerializer(Symfony |
public supportsDenormalization(?mixed $data, string $type, ?string $format = NULL, array $context = []) : bool |
public supportsNormalization(?mixed $data, ?string $format = NULL, array $context = []) : bool |
Constants |
protected Symfony
|
Properties |
protected ?Symfony |
protected array Symfony\Component\Serializer\Normalizer\AbstractNormalizer::$defaultContext = ['allow_extra_attributes' => true, 'circular_reference_handler' => NULL, 'circular_reference_limit' => 1, 'ignored_attributes' => []] |
protected ?Symfony |
protected ?Symfony |
Methods |
protected final Symfony\Component\Serializer\Normalizer\AbstractNormalizer::applyCallbacks(?mixed $value, object|string $object, string $attribute, ?string $format, array $context) : ?mixed |
protected final Symfony\Component\Serializer\Normalizer\AbstractNormalizer::applyFilterBool(ReflectionParameter $parameter, ?mixed $value, array $context) : ?mixed |
protected Symfony\Component\Serializer\Normalizer\AbstractNormalizer::createChildContext(array $parentContext, string $attribute, ?string $format) : array
|
protected Symfony\Component\Serializer\Normalizer\AbstractNormalizer::denormalizeParameter(ReflectionClass $class, ReflectionParameter $parameter, string $parameterName, ?mixed $parameterData, array $context, ?string $format = NULL) : ?mixed
|
protected Symfony\Component\Serializer\Normalizer\AbstractNormalizer::extractObjectToPopulate(string $class, array $context, ?string $key = NULL) : ?object Extract the
|
protected Symfony\Component\Serializer\Normalizer\AbstractNormalizer::getAllowedAttributes(object|string $classOrObject, array $context, bool $attributesAsString = false) : array|bool Gets attributes to normalize using groups.
|
protected Symfony\Component\Serializer\Normalizer\AbstractNormalizer::getAttributeDenormalizationContext(string $class, string $attribute, array $context) : array Computes the denormalization context merged with current one. Metadata always wins over global context, as more specific.
|
protected Symfony\Component\Serializer\Normalizer\AbstractNormalizer::getAttributeMetadata(object|string $objectOrClass, string $attribute) : ?Symfony
|
protected Symfony\Component\Serializer\Normalizer\AbstractNormalizer::getAttributeNormalizationContext(object $object, string $attribute, array $context) : array Computes the normalization context merged with current one. Metadata always wins over global context, as more specific.
|
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.
|
protected Symfony\Component\Serializer\Normalizer\AbstractNormalizer::instantiateObject(array $data, string $class, array $context, ReflectionClass $reflectionClass, array|bool $allowedAttributes, ?string $format = NULL) : object 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.
|
protected Symfony\Component\Serializer\Normalizer\AbstractNormalizer::isAllowedAttribute(object|string $classOrObject, string $attribute, ?string $format = NULL, array $context = []) : bool Is this attribute allowed? |
protected Symfony\Component\Serializer\Normalizer\AbstractNormalizer::isCircularReference(object $object, array $context) : bool Detects if the configured circular reference limit is reached.
|
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.
|