Skip to content

Commit

Permalink
[Serializer] Deprecate AdvancedNameConverterInterface
Browse files Browse the repository at this point in the history
  • Loading branch information
mdoutreluingne authored and OskarStark committed Oct 7, 2024
1 parent 32cace0 commit 2c93089
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions components/serializer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -549,12 +549,12 @@ A custom name converter can handle such cases::

class OrgPrefixNameConverter implements NameConverterInterface
{
public function normalize(string $propertyName): string
public function normalize(string $propertyName, ?string $class = null, ?string $format = null, array $context = []): string
{
return 'org_'.$propertyName;
}

public function denormalize(string $propertyName): string
public function denormalize(string $propertyName, ?string $class = null, ?string $format = null, array $context = []): string
{
// removes 'org_' prefix
return str_starts_with($propertyName, 'org_') ? substr($propertyName, 4) : $propertyName;
Expand Down Expand Up @@ -584,12 +584,6 @@ and :class:`Symfony\\Component\\Serializer\\Normalizer\\PropertyNormalizer`::
$companyCopy = $serializer->deserialize($json, Company::class, 'json');
// Same data as $company

.. note::

You can also implement
:class:`Symfony\\Component\\Serializer\\NameConverter\\AdvancedNameConverterInterface`
to access the current class name, format and context.

.. _using-camelized-method-names-for-underscored-attributes:

CamelCase to snake_case
Expand Down

0 comments on commit 2c93089

Please sign in to comment.