Skip to content

New property modifier to avoid conversion in toArray method #781

@zelenomodrypes

Description

@zelenomodrypes

Just a quick idea. I'm calling AbstractEntity::toArray(ToArrayConverter::RELATIONSHIP_AS_ID) to set form values ​​from an entity, but I'm having trouble with some 1:m relationships that have many items in the collection, which ends up with an out of memory error.

So how about creating a new entity property modifier, for example {ignore} (or something with a better name), and properties with this modifier would not be included in the result of the AbstractEntity::toArray() method? It could also be used, for example, when serializing to JSON.

Now I have solved it with my own property modifier registered in neon that stores the information in PropertyMetadata::$args (I couldn't find a better place and this looks safe), then I call toArray(0) and then I have to go through the result and check for the occurrence of the modifier to decide whether or not to include the value in the result. Because in my case I can decide which values ​​make sense to return like this and which ones don't. Perhaps this could be considered as general functionality and could be implemented in this library.

What do you think?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions