-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
[Api][Checkout] Modify ShippingMethod and PaymentMethod paths on Checkout #11745
[Api][Checkout] Modify ShippingMethod and PaymentMethod paths on Checkout #11745
Conversation
f58ec77
to
03072b9
Compare
03072b9
to
6669f37
Compare
a837755
to
c79410f
Compare
|
||
namespace Sylius\Bundle\ApiBundle\Command; | ||
|
||
interface CommandAwareDataTransformerInterface |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added new tag interface, because some DataTransformer
can be executed only one in certain object, if we have, for example two DataTransformers
where supportsTransformation (...)
equals to us conditions, will be executed first in line .
c79410f
to
f8baa28
Compare
949bedd
to
45ba3a4
Compare
|
||
$shipment = $cart->getShipments()[$shipmentIdentifier]; | ||
$shipment = $this->getShipmentById($cart, $chooseShippingMethod->shipmentId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of checking id for all shipments, we have a repository method on ShipmentRepository::findOneByOrderId
. With it, we can skill foreach loop, as well, as fetching cart.
What is more, as we moved the definition of the route from cart to shipment, we should return shipment instead of cart.
src/Sylius/Bundle/ApiBundle/DataTransformer/CommandAwareInputDataTransformer.php
Outdated
Show resolved
Hide resolved
src/Sylius/Bundle/ApiBundle/DataTransformer/CommandAwareInputDataTransformer.php
Outdated
Show resolved
Hide resolved
|
||
public function getSubresourceIdAttributeKey(): string | ||
{ | ||
return 'shipmentId'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO, the command should not be aware of path definition details. An additional interface is ok, but I would prefer to make more detailed (get/setShipmentId), make additional transformer, where shipmentId
will be injected into the constructor.
Also, can you check if we can use parameters in route definition?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added getSubresourceIdAttributeKey
instead of details like get/setShipmentId, because i would use it in next cases like payment, out of the box without duplicated boilerplate code.
f6f4f43
to
c12ff32
Compare
81983b8
to
0e6a366
Compare
src/Sylius/Bundle/ApiBundle/Resources/config/api_resources/Order.xml
Outdated
Show resolved
Hide resolved
b4f4b5b
to
a4f0dab
Compare
src/Sylius/Bundle/ApiBundle/DependencyInjection/Compiler/CommandDataTransformerPass.php
Outdated
Show resolved
Hide resolved
src/Sylius/Bundle/ApiBundle/Resources/config/api_resources/Order.xml
Outdated
Show resolved
Hide resolved
e23e38d
to
9f60b6f
Compare
3002262
to
5905d78
Compare
5905d78
to
fc12d21
Compare
Thank you, Tomasz! 🎉 |
This PR was merged into the 1.8 branch. Discussion ---------- | Q | A | --------------- | ----- | Branch? | 1.8 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Related tickets | Following #11745 | License | MIT I've adjusted service names to follow our conventions, removed unneeded classes, and typehinted variadic expression Commits ------- a19f1ac [API] Adjust services names to common convention 4dbf19f [API] Add variadic typehint e878b19 [API] Refactored CommandAwareInputDataTransformer
This PR was merged into the 1.8 branch. Discussion ---------- | Q | A | --------------- | ----- | Branch? | 1.8 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Related tickets | Following Sylius/Sylius#11745 | License | MIT I've adjusted service names to follow our conventions, removed unneeded classes, and typehinted variadic expression Commits ------- a19f1ac1a7f902e9183979fd414ef2ab3063ee96 [API] Adjust services names to common convention 4dbf19f7224992749c2ed3b14e43aba15866cd5c [API] Add variadic typehint e878b1935ac351ac0214a50060b940abd43f4a8e [API] Refactored CommandAwareInputDataTransformer
Its continue: #11735