Skip to content
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

Merged
merged 10 commits into from
Apr 29, 2021

Conversation

Tomanhez
Copy link
Contributor

@Tomanhez Tomanhez commented Mar 28, 2021

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

@Tomanhez Tomanhez requested a review from a team as a code owner March 28, 2021 21:27
@probot-autolabeler probot-autolabeler bot added the API APIs related issues and PRs. label Mar 28, 2021
@Tomanhez Tomanhez force-pushed the convert-iri-to-code-in-command branch 5 times, most recently from 3d618f7 to 7762ff4 Compare March 29, 2021 07:27
@Tomanhez Tomanhez force-pushed the convert-iri-to-code-in-command branch from 7762ff4 to 03a4211 Compare March 29, 2021 11:54
@probot-autolabeler probot-autolabeler bot added the Maintenance CI configurations, READMEs, releases, etc. label Mar 29, 2021
@Tomanhez Tomanhez force-pushed the convert-iri-to-code-in-command branch 2 times, most recently from cbf5597 to 6d3588b Compare March 29, 2021 12:05
@Tomanhez Tomanhez force-pushed the convert-iri-to-code-in-command branch 3 times, most recently from 783e179 to e93c345 Compare March 30, 2021 09:41
@AdamKasp
Copy link
Contributor

@Tomanhez, before potentially merge, you should add specs for it, and all classes should be @experimental

@AdamKasp
Copy link
Contributor

And probably you should update the description of this PR :)
And it is a new and custom logic, so I suggest adding a doc with an explanation of how it works and how to use it (maybe ADR?

@Tomanhez Tomanhez force-pushed the convert-iri-to-code-in-command branch 5 times, most recently from cf59028 to 53a4d93 Compare March 30, 2021 10:30
@Tomanhez Tomanhez force-pushed the convert-iri-to-code-in-command branch from 53a4d93 to 574bd5a Compare March 31, 2021 05:59
GSadee added a commit that referenced this pull request Mar 31, 2021
…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
GSadee added a commit to Sylius/SyliusApiBundle that referenced this pull request Mar 31, 2021
…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
@Tomanhez Tomanhez force-pushed the convert-iri-to-code-in-command branch 2 times, most recently from 3261f10 to 4e2626d Compare April 13, 2021 11:58
Copy link
Member

@CoderMaggie CoderMaggie left a 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 🖖🏼

adr/2021_04_15_using_iri_instead_of_code_id.md Outdated Show resolved Hide resolved
adr/2021_04_15_using_iri_instead_of_code_id.md Outdated Show resolved Hide resolved
adr/2021_04_15_using_iri_instead_of_code_id.md Outdated Show resolved Hide resolved
adr/2021_04_15_using_iri_instead_of_code_id.md Outdated Show resolved Hide resolved
Copy link
Member

@GSadee GSadee left a 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?

@Tomanhez Tomanhez force-pushed the convert-iri-to-code-in-command branch 2 times, most recently from 144fd86 to aa11089 Compare April 15, 2021 14:42
adr/2021_04_15_using_iri_instead_of_code_id.md Outdated Show resolved Hide resolved
adr/2021_04_15_using_iri_instead_of_code_id.md Outdated Show resolved Hide resolved
adr/2021_04_15_using_iri_instead_of_code_id.md Outdated Show resolved Hide resolved
adr/2021_04_15_using_iri_instead_of_code_id.md Outdated Show resolved Hide resolved
adr/2021_04_15_using_iri_instead_of_code_id.md Outdated Show resolved Hide resolved
@Tomanhez Tomanhez force-pushed the convert-iri-to-code-in-command branch from aa11089 to dcb1f7d Compare April 16, 2021 06:39
@arti0090 arti0090 force-pushed the convert-iri-to-code-in-command branch 3 times, most recently from e780947 to 33a50d8 Compare April 29, 2021 07:34
@arti0090 arti0090 force-pushed the convert-iri-to-code-in-command branch 3 times, most recently from 86973cd to 6b438bf Compare April 29, 2021 10:02
@arti0090 arti0090 force-pushed the convert-iri-to-code-in-command branch from 6b438bf to 786a7d6 Compare April 29, 2021 11:39
Comment on lines +164 to +173
<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>
Copy link
Member

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?

Comment on lines +55 to +62
/** @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]);
}
Copy link
Member

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'));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$this->assertSame('3', $converter->getIdentifier('/users/3/nexts/5'));
$converter->getIdentifier('/users/3/nexts/5');

@lchrusciel lchrusciel merged commit 43e3e8e into Sylius:master Apr 29, 2021
@lchrusciel
Copy link
Member

lchrusciel commented Apr 29, 2021

Thanks, Tomasz & Artur! 🥇

AdamKasp added a commit that referenced this pull request Jul 22, 2021
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API APIs related issues and PRs. Maintenance CI configurations, READMEs, releases, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants