Methods |
public Symfony\Component\Serializer\Context\Normalizer\AbstractNormalizerContextBuilder::toArray() : array - return array<string,mixed>
|
public Symfony\Component\Serializer\Context\Normalizer\AbstractNormalizerContextBuilder::withAllowExtraAttributes(?bool $allowExtraAttributes) : static If AbstractNormalizer::ATTRIBUTES are specified, and the source has fields that are not part of that list,
configures whether to ignore those attributes or throw an ExtraAttributesException. |
public Symfony\Component\Serializer\Context\Normalizer\AbstractNormalizerContextBuilder::withAttributes(?array $attributes) : static Configures attributes to (de)normalize. For nested structures, this list needs to reflect the object tree.
Eg: ['foo', 'bar', 'object' => ['baz']]
- param (string|array)[]|null $attributes
- throws \InvalidArgumentException
|
public Symfony\Component\Serializer\Context\Normalizer\AbstractNormalizerContextBuilder::withCallbacks(?array $callbacks) : static Configures an hashmap of field name => callable to normalize this field. The callable is called if the field is encountered with the arguments:
- mixed $attributeValue value of this field
- object $object the whole object being normalized
- string $attributeName name of the attribute being normalized
- string $format the requested format
- array<string, mixed> $context the serialization context
- param array<string,callable>|null $callbacks
|
public Symfony\Component\Serializer\Context\Normalizer\AbstractNormalizerContextBuilder::withCircularReferenceHandler(?callable $circularReferenceHandler) : static Configures an handler to call when a circular reference has been detected. If no handler is specified, 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\Context\Normalizer\AbstractNormalizerContextBuilder::withCircularReferenceLimit(?int $circularReferenceLimit) : static Configures how many loops of circular reference to allow while normalizing. The value 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.
Must be strictly positive.
- param positive-int|null $circularReferenceLimit
|
public Symfony\Component\Serializer\Context\Normalizer\AbstractNormalizerContextBuilder::withContext(Symfony\Component\Serializer\Context\ContextBuilderInterface|array $context) : static - param \ContextBuilderInterface|array<string,mixed> $context
|
public withDeepObjectToPopulate(?bool $deepObjectToPopulate) : static Configures whether 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 AbstractNormalizer::OBJECT_TO_POPULATE. |
public Symfony\Component\Serializer\Context\Normalizer\AbstractNormalizerContextBuilder::withDefaultConstructorArguments(?array $defaultConstructorArguments) : static Configures a hashmap of classes containing hashmaps of constructor argument => default value. The names need to match the parameter names in the constructor arguments.
Eg: [Foo::class => ['foo' => true, 'bar' => 0]]
- param array<class-string,array<string,mixed>>|null $defaultConstructorArguments
|
public Symfony\Component\Serializer\Context\Normalizer\AbstractNormalizerContextBuilder::withDefaultContructorArguments(?array $defaultContructorArguments) : static - deprecated since Symfony 7.1, use withDefaultConstructorArguments(?array $defaultConstructorArguments)" instead
- param array<class-string,array<string,mixed>>|null $defaultContructorArguments
|
public withDepthKeyPattern(?string $depthKeyPattern) : static Configures a pattern to keep track of the current depth. Must contain exactly two string placeholders. - throws \InvalidArgumentException
|
public withDisableTypeEnforcement(?bool $disableTypeEnforcement) : static Configures whether verifying types match during denormalization. |
public withEnableMaxDepth(?bool $enableMaxDepth) : static Configures whether to respect the max depth metadata on fields. |
public withExcludeFromCacheKeys(?array $excludeFromCacheKeys) : static Configures which context key are not relevant to determine which attributes
of an object to (de)normalize. - param list<string>|null $excludeFromCacheKeys
|
public Symfony\Component\Serializer\Context\Normalizer\AbstractNormalizerContextBuilder::withGroups(array|string|?null $groups) : static Configures groups containing attributes to (de)normalize. - param list<string>|string|null $groups
|
public Symfony\Component\Serializer\Context\Normalizer\AbstractNormalizerContextBuilder::withIgnoredAttributes(?array $ignoredAttributes) : static Configures attributes to be skipped when normalizing an object tree. This list is applied to each element of nested structures.
Eg: ['foo', 'bar']
Note: The behaviour for nested structures is different from ATTRIBUTES
for historical reason. Aligning the behaviour would be a BC break.
- param list<string>|null $ignoredAttributes
|
public withMaxDepthHandler(?callable $maxDepthHandler) : static Configures a 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:
- mixed $attributeValue value of this field
- object $object the whole object being normalized
- string $attributeName name of the attribute being normalized
- string $format the requested format
- array<string, mixed> $context the serialization context
|
public Symfony\Component\Serializer\Context\Normalizer\AbstractNormalizerContextBuilder::withObjectToPopulate(?object $objectToPopulate) : static Configures an object to be updated instead of creating a new instance. If you have a nested structure, child objects will be overwritten with
new instances unless you set AbstractObjectNormalizer::DEEP_OBJECT_TO_POPULATE to true. |
public withPreserveEmptyObjects(?bool $preserveEmptyObjects) : static Configures whether an empty object should be kept as an object (in
JSON: {}) or converted to a list (in JSON: []). |
public Symfony\Component\Serializer\Context\Normalizer\AbstractNormalizerContextBuilder::withRequireAllProperties(?bool $requireAllProperties = true) : static Configures requiring all properties to be listed in the input instead
of falling back to null for nullable ones. |
public withSkipNullValues(?bool $skipNullValues) : static Configures whether fields with the value null should be output during normalization.
|
public withSkipUninitializedValues(?bool $skipUninitializedValues) : static Configures whether uninitialized typed class properties should be excluded during normalization. |