Closed joshuataylor closed 8 years ago
Yes. See the example of the documentation:
hide_properties
aliased_properties
# app/config/serializer/acme_domain_dummy_post.yml
mapping:
class: Acme\Domain\Dummy\Post
alias: Message
aliased_properties:
author: author
title: headline
content: body
hide_properties: []
id_properties:
- postId
urls:
self: get_post ## @Route name
comments: get_post_comments ## @Route name
relationships:
author:
related: get_post_author ## @Route name
self: get_post_author_relationship ## @Route name
Are hidden properties still processed by the serializer, just hidden from the final result?
It seems that when I pass through a simple entity (id, createdAt, updatedAt, title) it works fine.
But when I do something a little more complicated (ie: Post, which has Comments, which has something, which has something), even with the yml files configured for all the fields it refuses to work and returns a 502.
This might be the cyclical reference Doctrine entities have. Hidden properties are not transformed but are initially read at the time being.
I'm working on this. I know I can fix it, but it's hard because of the Doctrine Proxies. Even the people at Doctrine are working on fixing this as it's a major concern for many. Symfony 2 managed to work around this with their serialized, so I must investigate and apply the fix.
Meanwhile you should use the main approach, which is mapping data to a new object and serialize that, as other Symfony packages are doing. I'm sorry =\
All good, this is an amazing library :).
I'm still hoping to add more features which will make your life even easier :+1:
Hi there, sorry for commenting on a closed issue.
Could this be the reason I'm getting Error: Maximum function nesting level of '1000' reached, aborting!
when serializing a Doctrine entity? As far as I could dig it had something to do with serializing a doctrine's PersistenCollection, but it looks complex.
Could it be possible to integrate the library with Symfony's Serializer component?
Finally, do you have any links to packages using thea approach of a new object? I could use an example.
Thanks in advance, and keep up the good work! :smile:
Ohh Doctrine...
On the mean time, you've have to create an Adapter/Transformer and build an object that does not share the problems of Doctrine cyclic class dependencies...
I'm working on a solution for this
Got it, thanks!
With the symfony serializer (or JMS), you can either use groups or config to dictate which properties should be serialized.
Can we do the same thing here?