Skip to content

Commit

Permalink
refactor #12206 [Api][OrderItem][OrderItemUnit] Refactor api serializ…
Browse files Browse the repository at this point in the history
…ation groups (Tomanhez)

This PR was merged into the 1.9-dev branch.
labels: bc-break

Discussion
----------

| Q               | A
| --------------- | -----
| Branch?         | master
| Bug fix?        | yes
| New feature?    | no
| BC breaks?      | yes
| Deprecations?   | no
| License         | MIT

- [x]  OrderItem
- [x] OrderItemUnit

Commits
-------

5948089 Refactor Item and Unit serialization groups
  • Loading branch information
lchrusciel authored and Tomanhez committed Jan 7, 2021
2 parents 4c8b8db + 5948089 commit 1817a3a
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 61 deletions.
4 changes: 4 additions & 0 deletions UPGRADE-1.8.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,13 @@ If you are using they on your custom entity `api_resource` configuration or seri
`order:create` changed to: `shop:order:create`
`order:read` changed to: `admin:order:read`
`order:update` changed to: `admin:order:update`
`order_item:read` changed to: `admin:order_item:read` and `shop:order_item:read`
`order_item_unit:read` changed to: `admin:order_item_unit:read` and `shop:order_item_unit:read`
`product:create` changed to: `admin:product:create`
`product:read` changed to: `admin:product:read` and `shop:product:read`
`product:update` changed to: `admin:product:update`
`province:read` changed to: `admin:province:read`
`province:update` changed to: `admin:province:update`
`shop:currencies:read` changed to: `shop:currency:read`
`shop:customer:write` changed to: `shop:customer:create`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,23 @@
xsi:schemaLocation="https://api-platform.com/schema/metadata https://api-platform.com/schema/metadata/metadata-2.0.xsd"
>
<resource class="%sylius.model.order_item.class%" shortName="OrderItem">
<attribute name="normalization_context">
<attribute name="groups">
<attribute>order_item:read</attribute>
</attribute>
</attribute>

<collectionOperations />

<itemOperations>
<itemOperation name="admin_get">
<attribute name="method">GET</attribute>
<attribute name="path">/admin/order-items/{id}</attribute>
<attribute name="normalization_context">
<attribute name="groups">admin:order_item:read</attribute>
</attribute>
</itemOperation>

<itemOperation name="shop_get">
<attribute name="method">GET</attribute>
<attribute name="path">/shop/order-items/{id}</attribute>
<attribute name="normalization_context">
<attribute name="groups">shop:order_item:read</attribute>
</attribute>
</itemOperation>
</itemOperations>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,26 @@
xsi:schemaLocation="https://api-platform.com/schema/metadata https://api-platform.com/schema/metadata/metadata-2.0.xsd"
>
<resource class="%sylius.model.order_item_unit.class%" shortName="OrderItemUnit">
<attribute name="normalization_context">
<attribute name="groups">
<attribute>order_item_unit:read</attribute>
</attribute>
</attribute>
<collectionOperations />

<itemOperations>
<itemOperation name="admin_get">
<attribute name="method">GET</attribute>
<attribute name="path">/admin/order-item-units/{id}</attribute>
<attribute name="normalization_context">
<attribute name="groups">admin:order_item_unit:read</attribute>
</attribute>
</itemOperation>

<itemOperation name="shop_get">
<attribute name="method">GET</attribute>
<attribute name="path">/shop/order-item-units/{id}</attribute>
<attribute name="normalization_context">
<attribute name="groups">shop:order_item_unit:read</attribute>
</attribute>
</itemOperation>
</itemOperations>

<collectionOperations />

<property name="id" identifier="true" writable="false" />
<property name="shippable" />
</resource>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,23 @@
<resource class="%sylius.model.promotion.class%" shortName="Promotion">
<attribute name="route_prefix">admin</attribute>

<attribute name="normalization_context">
<attribute name="groups">
<attribute>admin:promotion:read</attribute>
</attribute>
</attribute>

<attribute name="validation_groups">sylius</attribute>

<collectionOperations>
<collectionOperation name="admin_get">
<attribute name="method">GET</attribute>
<attribute name="normalization_context">
<attribute name="groups">admin:promotion:read</attribute>
</attribute>
</collectionOperation>
</collectionOperations>

<itemOperations>
<itemOperation name="admin_get">
<attribute name="method">GET</attribute>
<attribute name="normalization_context">
<attribute name="groups">admin:promotion:read</attribute>
</attribute>
</itemOperation>
<itemOperation name="admin_delete">
<attribute name="method">DELETE</attribute>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,20 @@
<resource class="%sylius.model.province.class%" shortName="Province">
<attribute name="route_prefix">admin</attribute>

<attribute name="normalization_context">
<attribute name="groups">
<attribute>province:read</attribute>
</attribute>
</attribute>

<attribute name="denormalization_context">
<attribute name="groups">
<attribute>province:update</attribute>
</attribute>
</attribute>

<attribute name="validation_groups">sylius</attribute>

<collectionOperations />

<itemOperations>
<itemOperation name="admin_get">
<attribute name="method">GET</attribute>
<attribute name="normalization_context">
<attribute name="groups">admin:province:read</attribute>
</attribute>

<attribute name="denormalization_context">
<attribute name="groups">admin:province:update</attribute>
</attribute>
</itemOperation>

<itemOperation name="admin_put">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,64 +17,79 @@
>
<class name="Sylius\Component\Core\Model\OrderItem">
<attribute name="id">
<group>shop:order:account:read</group>
<group>order_item:read</group>
<group>admin:order:read</group>
<group>admin:order_item:read</group>
<group>shop:cart:read</group>
<group>shop:order:account:read</group>
<group>shop:order_item:read</group>
</attribute>
<attribute name="code">
<group>order_item:read</group>
<group>admin:order:read</group>
<group>admin:order_item:read</group>
<group>shop:order_item:read</group>
</attribute>
<attribute name="order">
<group>order_item:read</group>
<group>admin:order_item:read</group>
<group>shop:order_item:read</group>
</attribute>
<attribute name="variant">
<group>shop:order:account:read</group>
<group>order_item:read</group>
<group>admin:order:read</group>
<group>admin:order_item:read</group>
<group>shop:cart:read</group>
<group>shop:order:account:read</group>
<group>shop:order_item:read</group>
</attribute>
<attribute name="quantity">
<group>shop:order:account:read</group>
<group>order_item:read</group>
<group>admin:order:read</group>
<group>admin:order_item:read</group>
<group>shop:cart:read</group>
<group>shop:order:account:read</group>
<group>shop:order_item:read</group>
</attribute>
<attribute name="unitPrice">
<group>order_item:read</group>
<group>admin:order_item:read</group>
<group>shop:order_item:read</group>
</attribute>
<attribute name="units">
<group>order_item:read</group>
<group>admin:order_item:read</group>
<group>shop:order_item:read</group>
</attribute>
<attribute name="adjustments">
<group>order_item:read</group>
<group>admin:order_item:read</group>
<group>shop:order_item:read</group>
</attribute>
<attribute name="adjustmentsRecursively">
<group>order_item:read</group>
<group>admin:order_item:read</group>
<group>shop:order_item:read</group>
</attribute>
<attribute name="adjustmentsTotal">
<group>order_item:read</group>
<group>admin:order_item:read</group>
<group>shop:order_item:read</group>
</attribute>
<attribute name="adjustmentsTotalRecursively">
<group>order_item:read</group>
<group>admin:order_item:read</group>
<group>shop:order_item:read</group>
</attribute>
<attribute name="product">
<group>order_item:read</group>
<group>admin:order_item:read</group>
<group>shop:order_item:read</group>
</attribute>
<attribute name="productName">
<group>shop:order:account:read</group>
<group>order_item:read</group>
<group>shop:cart:read</group>
<group>admin:order:read</group>
<group>admin:order_item:read</group>
<group>shop:cart:read</group>
<group>shop:order:account:read</group>
<group>shop:order_item:read</group>
</attribute>
<attribute name="subtotal">
<group>order_item:read</group>
<group>admin:order:read</group>
<group>admin:order_item:read</group>
<group>shop:order_item:read</group>
</attribute>
<attribute name="total">
<group>order_item:read</group>
<group>admin:order:read</group>
<group>admin:order_item:read</group>
<group>shop:order_item:read</group>
</attribute>
</class>
</serializer>
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@
>
<class name="Sylius\Component\Core\Model\OrderItemUnit">
<attribute name="id">
<group>order_item_unit:read</group>
<group>admin:order_item_unit:read</group>
<group>shop:order_item_unit:read</group>
</attribute>
<attribute name="shippable">
<group>order_item_unit:read</group>
<group>admin:order_item_unit:read</group>
<group>shop:order_item_unit:read</group>
</attribute>
</class>
</serializer>
Original file line number Diff line number Diff line change
Expand Up @@ -17,32 +17,32 @@
>
<class name="Sylius\Component\Addressing\Model\Province">
<attribute name="id">
<group>province:read</group>
<group>admin:province:read</group>
</attribute>
<attribute name="createdAt">
<group>province:read</group>
<group>admin:province:read</group>
</attribute>
<attribute name="updatedAt">
<group>province:read</group>
<group>admin:province:read</group>
</attribute>
<attribute name="code">
<group>admin:country:create</group>
<group>admin:country:update</group>
<group>shop:country:read</group>
<group>province:read</group>
<group>admin:province:read</group>
</attribute>
<attribute name="name">
<group>admin:country:create</group>
<group>admin:country:update</group>
<group>shop:country:read</group>
<group>province:read</group>
<group>province:update</group>
<group>admin:province:read</group>
<group>admin:province:update</group>
</attribute>
<attribute name="abbreviation">
<group>admin:country:create</group>
<group>admin:country:update</group>
<group>province:read</group>
<group>province:update</group>
<group>admin:province:read</group>
<group>admin:province:update</group>
</attribute>
</class>
</serializer>

0 comments on commit 1817a3a

Please sign in to comment.