Forked from dsbaars/Representation.CollectionRepresentation.yml
Last active
June 3, 2019 13:06
-
-
Save igormukhingmailcom/fd5a6e577fc0ff7adbeeef09822ace14 to your computer and use it in GitHub Desktop.
JMSSerializerBundle groups and Hateoas.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/serializer/hateoas/AbstractSegmentedRepresentation.yml | |
Hateoas\Representation\AbstractSegmentedRepresentation: | |
exclusion_policy: ALL | |
expose: false | |
properties: | |
limit: | |
expose: true | |
groups: [ Default, Hateoas ] | |
total: | |
expose: true | |
groups: [ Default, Hateoas ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/packages/jms_serializer.yml | |
jms_serializer: | |
metadata: | |
directories: | |
hateoas: | |
namespace_prefix: "Hateoas\\Representation" | |
path: "%kernel.project_dir%/config/serializer/hateoas/" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/serializer/hateoas/CollectionRepresentation.yml | |
Hateoas\Representation\CollectionRepresentation: | |
exclusion_policy: ALL | |
expose: false | |
virtual_properties: | |
getResources: | |
serialized_name: items | |
expose: true | |
groups: [ Default, Hateoas ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/serializer/hateoas/PaginatedRepresentation.yml | |
Hateoas\Representation\PaginatedRepresentation: | |
exclusion_policy: ALL | |
expose: false | |
custom_accessor_order: [page, limit, pages, total] | |
relations: | |
- rel: self | |
href: | |
route: expr(object.getRoute()) | |
parameters: "expr(object.getParameters() + {page: object.getPage()})" | |
absolute: expr(object.isAbsolute()) | |
exclusion: | |
groups: [ Default, Hateoas ] | |
- rel: first | |
href: | |
route: expr(object.getRoute()) | |
parameters: "expr(object.getParameters() + {page: 1})" | |
absolute: expr(object.isAbsolute()) | |
exclusion: | |
groups: [ Default, Hateoas ] | |
- rel: last | |
href: | |
route: expr(object.getRoute()) | |
parameters: "expr(object.getParameters() + {page: object.getPages()})" | |
absolute: expr(object.isAbsolute()) | |
exclusion: | |
groups: [ Default, Hateoas ] | |
exclude_if: expr(object.getPages() === null) | |
- rel: next | |
href: | |
route: expr(object.getRoute()) | |
parameters: "expr(object.getParameters() + {page: object.getPage()+1})" | |
absolute: expr(object.isAbsolute()) | |
exclusion: | |
groups: [ Default, Hateoas ] | |
exclude_if: expr(object.getPages() !== null && (object.getPage() + 1) > object.getPages()) | |
- rel: previous | |
href: | |
route: expr(object.getRoute()) | |
parameters: "expr(object.getParameters() + {page: object.getPage()-1})" | |
absolute: expr(object.isAbsolute()) | |
exclusion: | |
groups: [ Default, Hateoas ] | |
exclude_if: expr((object.getPage() - 1) < 1) | |
properties: | |
page: | |
expose: true | |
groups: [ Default, Hateoas ] | |
limit: | |
expose: true | |
groups: [ Default, Hateoas ] | |
pages: | |
expose: true | |
groups: [ Default, Hateoas ] | |
total: | |
expose: true | |
groups: [ Default, Hateoas ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/serializer/hateoas/RouteAwareRepresentation.yml | |
Hateoas\Representation\RouteAwareRepresentation: | |
exclusion_policy: ALL | |
expose: false | |
properties: | |
inline: | |
expose: true | |
groups: [ Default, Hateoas ] | |
serialized_name: _embedded |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment