-
-
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][POC]Convert iri to code in command #12487
[Api][POC]Convert iri to code in command #12487
Conversation
Tomanhez
commented
Mar 28, 2021
•
edited
Loading
edited
Q | A |
---|---|
Branch? | master |
Bug fix? | no |
New feature? | yes |
BC breaks? | no |
Deprecations? | no |
License | MIT |
3d618f7
to
7762ff4
Compare
7762ff4
to
03a4211
Compare
cbf5597
to
6d3588b
Compare
src/Sylius/Bundle/ApiBundle/Converter/CommandFieldItemIriToIdConverter.php
Outdated
Show resolved
Hide resolved
src/Sylius/Bundle/ApiBundle/Converter/ItemIriToIdConverterInterface.php
Outdated
Show resolved
Hide resolved
src/Sylius/Bundle/ApiBundle/Serializer/CommandFieldItemIriToIdDenormalizer.php
Outdated
Show resolved
Hide resolved
783e179
to
e93c345
Compare
@Tomanhez, before potentially merge, you should add specs for it, and all classes should be |
And probably you should update the description of this PR :) |
cf59028
to
53a4d93
Compare
src/Sylius/Bundle/ApiBundle/Converter/CommandFieldItemIriToIdentifierStorage.php
Outdated
Show resolved
Hide resolved
src/Sylius/Bundle/ApiBundle/Converter/CommandFieldItemIriToIdentifierStorage.php
Outdated
Show resolved
Hide resolved
src/Sylius/Bundle/ApiBundle/Converter/CommandFieldItemIriToIdentifierStorageInterface.php
Outdated
Show resolved
Hide resolved
src/Sylius/Bundle/ApiBundle/Serializer/CommandFieldItemIriToIdentifierDenormalizer.php
Outdated
Show resolved
Hide resolved
src/Sylius/Bundle/ApiBundle/Serializer/CommandFieldItemIriToIdentifierDenormalizer.php
Outdated
Show resolved
Hide resolved
src/Sylius/Bundle/ApiBundle/Serializer/CommandFieldItemIriToIdentifierDenormalizer.php
Outdated
Show resolved
Hide resolved
src/Sylius/Bundle/ApiBundle/Serializer/CommandFieldItemIriToIdentifierDenormalizer.php
Outdated
Show resolved
Hide resolved
53a4d93
to
574bd5a
Compare
…hez) This PR was merged into the 1.10-dev branch. Discussion ---------- | Q | A | --------------- | ----- | Branch? | master | Bug fix? | yes | New feature? | yes | BC breaks? | no | Deprecations? | no | License | MIT <!-- - Bug fixes must be submitted against the 1.7 or 1.8 branch (the lowest possible) - Features and deprecations must be submitted against the master branch - Make sure that the correct base branch is set To be sure you are not breaking any Backward Compatibilities, check the documentation: https://docs.sylius.com/en/latest/book/organization/backward-compatibility-promise.html --> This is extension and improvement for create generic transformation command field iri's to code: #12487 Commits ------- 8cb5087 Convert AddProductReview product iri to productCode 3521679 Add spec for AddPRoductReviewCommandFieldItemIriToIdentifierDenormalize
…hez) This PR was merged into the 1.10-dev branch. Discussion ---------- | Q | A | --------------- | ----- | Branch? | master | Bug fix? | yes | New feature? | yes | BC breaks? | no | Deprecations? | no | License | MIT <!-- - Bug fixes must be submitted against the 1.7 or 1.8 branch (the lowest possible) - Features and deprecations must be submitted against the master branch - Make sure that the correct base branch is set To be sure you are not breaking any Backward Compatibilities, check the documentation: https://docs.sylius.com/en/latest/book/organization/backward-compatibility-promise.html --> This is extension and improvement for create generic transformation command field iri's to code: Sylius/Sylius#12487 Commits ------- 8cb5087106ad60e137290d7af342502045e78f3c Convert AddProductReview product iri to productCode 35216795264ef19246a7717102d757057bfd96d7 Add spec for AddPRoductReviewCommandFieldItemIriToIdentifierDenormalize
3261f10
to
4e2626d
Compare
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.
The 🇺🇸 language police at your service 🖖🏼
src/Sylius/Bundle/ApiBundle/Converter/ItemIriToIdentifierConverterInterface.php
Outdated
Show resolved
Hide resolved
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.
Could you list the rest of the commands and fields that should be changed to the new approach?
src/Sylius/Bundle/ApiBundle/spec/Map/CommandItemIriArgumentToIdentifierMapSpec.php
Outdated
Show resolved
Hide resolved
src/Sylius/Bundle/ApiBundle/spec/Map/CommandItemIriArgumentToIdentifierMapSpec.php
Outdated
Show resolved
Hide resolved
src/Sylius/Bundle/ApiBundle/spec/Map/CommandItemIriArgumentToIdentifierMapSpec.php
Outdated
Show resolved
Hide resolved
144fd86
to
aa11089
Compare
aa11089
to
dcb1f7d
Compare
…ArgumentToIdentifierMap
e780947
to
33a50d8
Compare
86973cd
to
6b438bf
Compare
adr/2021_04_15_using_iri_as_api_resource_identifier_in_request_instead_of_code_id.md
Outdated
Show resolved
Hide resolved
6b438bf
to
786a7d6
Compare
<argument type="collection"> | ||
<argument key="Sylius\Bundle\ApiBundle\Command\AddProductReview">product</argument> | ||
<argument key="Sylius\Bundle\ApiBundle\Command\Checkout\ChoosePaymentMethod">paymentMethod</argument> | ||
<argument key="Sylius\Bundle\ApiBundle\Command\Account\ChangePaymentMethod">paymentMethod</argument> | ||
<argument key="Sylius\Bundle\ApiBundle\Command\RequestResetPasswordToken">locale</argument> | ||
<argument key="Sylius\Bundle\ApiBundle\Command\ResendVerificationEmail">locale</argument> | ||
<argument key="Sylius\Bundle\ApiBundle\Command\Cart\PickupCart">locale</argument> | ||
<argument key="Sylius\Bundle\ApiBundle\Command\Cart\AddItemToCart">productVariant</argument> | ||
<argument key="Sylius\Bundle\ApiBundle\Command\Checkout\ChooseShippingMethod">shippingMethod</argument> | ||
</argument> |
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.
That's a neat idea, but I'm afraid about this list expandability. One would have to override this service definition, therefore they will not receive changes to this collection that we will do in the later releases. We need some refactoring here. Probably configuration tree would be the best choice. Maybe second class for client-specific mappings?
/** @psalm-var class-string $inputClassName */ | ||
$inputClassName = $this->getInputClassName($context); | ||
|
||
$fieldName = $this->commandItemIriArgumentToIdentifierMap->get($inputClassName); | ||
|
||
$data['product'] = $product->getCode(); | ||
if (array_key_exists($fieldName, $data)) { | ||
$data[$fieldName] = $this->itemIriToIdentifierConverter->getIdentifier($data[$fieldName]); | ||
} |
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.
Also, improvement for the second iteration, but what is blocking us from checking if the field consists IRI and execute this logic on all fields like this? This way, we could remove the whole map from the concept
$identifierConverter->convert(['id' => 3, 'nextId' => 5], AddProductReview::class)->willReturn(['3', '5']); | ||
$converter = new ItemIriToIdentifierConverter($router->reveal(), $identifierConverter->reveal()); | ||
|
||
$this->assertSame('3', $converter->getIdentifier('/users/3/nexts/5')); |
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.
$this->assertSame('3', $converter->getIdentifier('/users/3/nexts/5')); | |
$converter->getIdentifier('/users/3/nexts/5'); |
Thanks, Tomasz & Artur! 🥇 |
…RIs to identifiers (Tomanhez, GSadee) This PR was merged into the 1.11-dev branch. Discussion ---------- | Q | A | --------------- | ----- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Related tickets | #12487 | License | MIT Commits ------- feb3022 Remove redundant CommandItemIriArgumentToIdentifierMap fe15cd4 Add CommandFieldItemIriToIdentifierAwareInterface 4492d10 Modify CommandFieldItemIriToIdentifierDenormalizer ae2e91a Fix CommandFieldItemIriToIdentifierDenormalizer and its spec 1d5dc71 [API] Add missing experimental tag 647dde2 [API] Change name of iri to identifier converter 32d9c18 [API] Change name of denormalizer for converting iris to identifiers 0ee8cae [API] Change name of interface to mark commands with convertible arguments a87ef15 [API] Use an endpoint that is not customized in ApiBundle tests