Skip to content

[RFC] Using decoration over inheritance for Normalizers #2355

Closed
@joelwurtz

Description

@joelwurtz

Actually all Item Normalizers (HAL / JSON-LD / Json Api) extends the AbstractItemNormalizer to add their context and informations.

I'm actually working on a library that change the way of serializing / deserializing object by using generated code (https://github.com/janephp/automapper) insted of the PropertyAccess Component. This change allows significant performance boost

see https://blackfire.io/profiles/compare/c6fa2145-c3aa-46f9-a211-538c6dc576a5/graph or https://travis-ci.org/php-serializers/ivory-serializer-benchmark/builds/460744766?utm_source=github_status&utm_medium=notification

The example try to serilalize 10000 objects, that's an use case that we have where we need to return a lots of data and where we cannot use cache

However for correct integration with API Platform i need to rewrite all the existing normalizers since class are final and use inheritance.

I belive by using decoration (injecting a normalizer that does the item normalization / denormalization instead of calling the parent class) this would be far easier to handle this use case. I'm willing to work on the PR if that's something you want to support.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions