Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save igormukhingmailcom/fd5a6e577fc0ff7adbeeef09822ace14 to your computer and use it in GitHub Desktop.

Select an option

Save igormukhingmailcom/fd5a6e577fc0ff7adbeeef09822ace14 to your computer and use it in GitHub Desktop.

Revisions

  1. igormukhingmailcom revised this gist Jun 3, 2019. No changes.
  2. igormukhingmailcom revised this gist Jun 3, 2019. No changes.
  3. igormukhingmailcom revised this gist Jun 3, 2019. No changes.
  4. igormukhingmailcom revised this gist Jun 3, 2019. 5 changed files with 44 additions and 35 deletions.
    11 changes: 11 additions & 0 deletions AbstractSegmentedRepresentation.yml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    # 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 ]
    16 changes: 6 additions & 10 deletions Representation.CollectionRepresentation.yml
    Original file line number Diff line number Diff line change
    @@ -1,13 +1,9 @@
    # config/serializer/hateoas/CollectionRepresentation.yml
    Hateoas\Representation\CollectionRepresentation:
    exclusion_policy: all
    exclude: false
    expose: true
    properties:
    rel:
    exclude: false
    expose: true
    groups: [ Default, Hateoas ]
    resources:
    exclude: false
    exclusion_policy: ALL
    expose: false
    virtual_properties:
    getResources:
    serialized_name: items
    expose: true
    groups: [ Default, Hateoas ]
    42 changes: 17 additions & 25 deletions Representation.PaginatedRepresentation.yml
    Original file line number Diff line number Diff line change
    @@ -1,65 +1,57 @@
    # 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:
    parameters:
    page: expr(object.getPage())
    _format: json
    parameters: "expr(object.getParameters() + {page: object.getPage()})"
    absolute: expr(object.isAbsolute())
    exclusion:
    groups: [Hateoas]
    groups: [ Default, Hateoas ]
    - rel: first
    href:
    route: expr(object.getRoute())
    parameters:
    page: 1
    _format: json
    parameters: "expr(object.getParameters() + {page: 1})"
    absolute: expr(object.isAbsolute())
    exclusion:
    groups: [Hateoas]
    groups: [ Default, Hateoas ]
    - rel: last
    href:
    route: expr(object.getRoute())
    parameters:
    page: expr(object.getPages())
    _format: json
    parameters: "expr(object.getParameters() + {page: object.getPages()})"
    absolute: expr(object.isAbsolute())
    exclusion:
    groups: [Hateoas]
    groups: [ Default, Hateoas ]
    exclude_if: expr(object.getPages() === null)
    - rel: next
    href:
    route: expr(object.getRoute())
    parameters:
    page: expr(object.getPage()+1)
    _format: json
    parameters: "expr(object.getParameters() + {page: object.getPage()+1})"
    absolute: expr(object.isAbsolute())
    exclusion:
    groups: [Hateoas]
    groups: [ Default, Hateoas ]
    exclude_if: expr(object.getPages() !== null && (object.getPage() + 1) > object.getPages())
    - rel: previous
    href:
    route: expr(object.getRoute())
    parameters:
    page: expr(object.getPage()-1)
    _format: json
    parameters: "expr(object.getParameters() + {page: object.getPage()-1})"
    absolute: expr(object.isAbsolute())
    exclusion:
    groups: [Hateoas]
    groups: [ Default, Hateoas ]
    exclude_if: expr((object.getPage() - 1) < 1)
    properties:
    page:
    expose: true
    groups: [Hateoas]
    groups: [ Default, Hateoas ]
    limit:
    expose: true
    groups: [Hateoas]
    groups: [ Default, Hateoas ]
    pages:
    expose: true
    groups: [Hateoas]
    groups: [ Default, Hateoas ]
    total:
    expose: true
    groups: [Hateoas]
    groups: [ Default, Hateoas ]
    3 changes: 3 additions & 0 deletions Representation.RouteAwareRepresentation.yml
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,7 @@
    # config/serializer/hateoas/RouteAwareRepresentation.yml
    Hateoas\Representation\RouteAwareRepresentation:
    exclusion_policy: ALL
    expose: false
    properties:
    inline:
    expose: true
    7 changes: 7 additions & 0 deletions jms_serializer.yml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    # config/packages/jms_serializer.yml
    jms_serializer:
    metadata:
    directories:
    hateoas:
    namespace_prefix: "Hateoas\\Representation"
    path: "%kernel.project_dir%/config/serializer/hateoas/"
  5. @dsbaars dsbaars created this gist May 23, 2015.
    13 changes: 13 additions & 0 deletions Representation.CollectionRepresentation.yml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    Hateoas\Representation\CollectionRepresentation:
    exclusion_policy: all
    exclude: false
    expose: true
    properties:
    rel:
    exclude: false
    expose: true
    groups: [ Default, Hateoas ]
    resources:
    exclude: false
    expose: true
    groups: [ Default, Hateoas ]
    65 changes: 65 additions & 0 deletions Representation.PaginatedRepresentation.yml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,65 @@
    Hateoas\Representation\PaginatedRepresentation:
    custom_accessor_order: [page, limit, pages, total]
    relations:
    - rel: self
    href:
    route: expr(object.getRoute())
    parameters:
    parameters:
    page: expr(object.getPage())
    _format: json
    absolute: expr(object.isAbsolute())
    exclusion:
    groups: [Hateoas]
    - rel: first
    href:
    route: expr(object.getRoute())
    parameters:
    page: 1
    _format: json
    absolute: expr(object.isAbsolute())
    exclusion:
    groups: [Hateoas]
    - rel: last
    href:
    route: expr(object.getRoute())
    parameters:
    page: expr(object.getPages())
    _format: json
    absolute: expr(object.isAbsolute())
    exclusion:
    groups: [Hateoas]
    exclude_if: expr(object.getPages() === null)
    - rel: next
    href:
    route: expr(object.getRoute())
    parameters:
    page: expr(object.getPage()+1)
    _format: json
    absolute: expr(object.isAbsolute())
    exclusion:
    groups: [Hateoas]
    exclude_if: expr(object.getPages() !== null && (object.getPage() + 1) > object.getPages())
    - rel: previous
    href:
    route: expr(object.getRoute())
    parameters:
    page: expr(object.getPage()-1)
    _format: json
    absolute: expr(object.isAbsolute())
    exclusion:
    groups: [Hateoas]
    exclude_if: expr((object.getPage() - 1) < 1)
    properties:
    page:
    expose: true
    groups: [Hateoas]
    limit:
    expose: true
    groups: [Hateoas]
    pages:
    expose: true
    groups: [Hateoas]
    total:
    expose: true
    groups: [Hateoas]
    6 changes: 6 additions & 0 deletions Representation.RouteAwareRepresentation.yml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,6 @@
    Hateoas\Representation\RouteAwareRepresentation:
    properties:
    inline:
    expose: true
    groups: [ Default, Hateoas ]
    serialized_name: _embedded