Lakion / Lionframe

Rapid API development framework for PHP.
http://lakion.com/lionframe
MIT License
214 stars 11 forks source link

Serialization groups #27

Open lube opened 8 years ago

lube commented 8 years ago

I cannot get serialization groups to work this is probably my fault, but maybe someone else is having the same issue and can find help here.

serialization file:

DemoBundle\Entity\Comment:
    exclusion_policy: ALL
    xml_root_name: comment
    properties:
        id:
            expose: true
            type: integer
        text:
            expose: true
            type: string
            groups: [foo]
        postId:
            expose: true
            type: DemoBundle\Entity\Post
            serialized_name: post

routing:

comment_api:
    resource: demo.comment
    type: sylius.api
    defaults:
        serialization_groups: [foo]
pjedrzejewski commented 8 years ago

Try with:

comment_api:
    resource: demo.comment
    type: sylius.api
    defaults:
        _sylius:
            serialization_groups: [foo]
lube commented 8 years ago

didn't work :/

getting: { }

lchrusciel commented 8 years ago

Try foo -> Default. If you are testing it on a index page, especially. Also, just as a remainder, clear cache ;)

lube commented 8 years ago

Im always clearing cache, good ol symfony.

You mean the name of the Serializtion group, instead of foo naming it Default?

lchrusciel commented 8 years ago

Yes, IIRC there were some issues with managing an index data for other serialization groups than Default. It had something to do with default serialization group in hateoas bundle, i suppose.

And, I know that clear:cache advise was a little bit trivial, but we sometimes forgot even the simplest things.

lube commented 8 years ago

Oh for sure, Symfony cache has bitten me before, no worries.

I'll try renaming the serialization group when I get back from work!