Skip to content

Commit

Permalink
feature #20273 [Serializer] Deprecate ``AdvancedNameConverterInterfac…
Browse files Browse the repository at this point in the history
…e`` (mdoutreluingne)

This PR was squashed before being merged into the 7.2 branch.

Discussion
----------

[Serializer] Deprecate ``AdvancedNameConverterInterface``

Fix #20266

Here, I don't know if I should modify or delete the `.. note::` block, what do you think?

Commits
-------

2c93089 [Serializer] Deprecate ``AdvancedNameConverterInterface``
  • Loading branch information
OskarStark committed Oct 7, 2024
2 parents 8aa8b1e + 2c93089 commit a30a669
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 a30a669

Please sign in to comment.