File tree 1 file changed +9
-2
lines changed
Filter options
1 file changed +9
-2
lines changed
Original file line number Diff line number Diff line change @@ -30,19 +30,26 @@ A custom name converter can handle such cases::
30
30
31
31
class OrgPrefixNameConverter implements NameConverterInterface
32
32
{
33
- public function normalize(string $propertyName): string
33
+ public function normalize(string $propertyName, string $class = null, ?string $format = null, array $context = [] ): string
34
34
{
35
35
// during normalization, add the prefix
36
36
return 'org_'.$propertyName;
37
37
}
38
38
39
- public function denormalize(string $propertyName): string
39
+ public function denormalize(string $propertyName, ?string $class = null, ?string $format = null, array $context = [] ): string
40
40
{
41
41
// remove the 'org_' prefix on denormalizing
42
42
return str_starts_with($propertyName, 'org_') ? substr($propertyName, 4) : $propertyName;
43
43
}
44
44
}
45
45
46
+ .. versionadded :: 7.1
47
+
48
+ Accessing the current class name, format and context via
49
+ :method: `Symfony\\ Component\\ Serializer\\ NameConverter\\ NameConverterInterface::normalize `
50
+ and :method: `Symfony\\ Component\\ Serializer\\ NameConverter\\ NameConverterInterface::denormalize `
51
+ was introduced in Symfony 7.1.
52
+
46
53
.. note ::
47
54
48
55
You can also implement
You can’t perform that action at this time.
0 commit comments