Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AccessorOrder : properties vs virtualProperty #512

Closed
tcardonne opened this issue Mar 30, 2016 · 3 comments
Closed

AccessorOrder : properties vs virtualProperty #512

tcardonne opened this issue Mar 30, 2016 · 3 comments

Comments

@tcardonne
Copy link

Hello,

The actual behavior of the serializer is to put virtual property on top of the resulting serialized string, but ...
Shouldn't be a way to set the accessor order like : "properties first, virtual property after ?"
I know it's possible to set this order with the @AccessorOrder property, but I think it could be easier.
Maybe I'm missing a feature of this bundle?

Regards,

@goetas
Copy link
Collaborator

goetas commented Mar 29, 2017

if the order of properties is what you need, then @AccessorOrder does exactly what you need

@goetas goetas closed this as completed Mar 29, 2017
@montera82
Copy link

i no this is clossed...but @goetas how would i be able to use accessOrder in yaml

---
Appbundle\Class\Foo:
  exclusion_policy: ALL
  properties:
    id:
      expose: true
      type: string
    name:
      expose: true
      type: string

i want name to come before ID...i could only see examples online to do this inline within the model class...any ideas

@goetas
Copy link
Collaborator

goetas commented Sep 24, 2017

Vendor\MyBundle\Model\ClassName:
    accessor_order: custom
    custom_accessor_order: [propertyName1, propertyName2, ..., propertyNameN]

see https://jmsyst.com/libs/serializer/master/reference/yml_reference

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants