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
[ApiBundle] Added remaining APIs for the Promotion resource. #15524
[ApiBundle] Added remaining APIs for the Promotion resource. #15524
Conversation
Wojdylak
commented
Nov 13, 2023
Q | A |
---|---|
Branch? | 1.13 |
Bug fix? | no |
New feature? | yes |
BC breaks? | no |
Deprecations? | yes |
Related tickets | N/A |
License | MIT |
Bunnyshell Preview Environment deletedAvailable commands:
|
a73d2df
to
862b8a6
Compare
SonarCloud Quality Gate failed. 6 Bugs No Coverage information Catch issues before they fail your Quality Gate with our IDE extension SonarLint |
b9b1b56
to
f9bf245
Compare
src/Sylius/Bundle/CoreBundle/Fixture/Factory/PromotionExampleFactory.php
Show resolved
Hide resolved
src/Sylius/Behat/Context/Api/Admin/ManagingPromotionsContext.php
Outdated
Show resolved
Hide resolved
src/Sylius/Behat/Context/Api/Admin/ManagingPromotionsContext.php
Outdated
Show resolved
Hide resolved
src/Sylius/Behat/Context/Api/Admin/ManagingPromotionsContext.php
Outdated
Show resolved
Hide resolved
src/Sylius/Behat/Context/Api/Admin/ManagingPromotionsContext.php
Outdated
Show resolved
Hide resolved
src/Sylius/Behat/Context/Api/Admin/ManagingPromotionsContext.php
Outdated
Show resolved
Hide resolved
src/Sylius/Bundle/ApiBundle/Resources/config/api_resources/PromotionTranslation.xml
Outdated
Show resolved
Hide resolved
<group>admin:promotion:create</group> | ||
<group>admin:promotion:update</group> | ||
<denormalization_context> | ||
<entry name="disable_type_enforcement">true</entry> |
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.
Why are you disabling it on the priority field?
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.
In the database, the priority column is not nullable, so serialization throws an error on null values. However, we want to allow sending null, because the setPriority
method accepts null.
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 question is whether we want to accept a null value if the db doesn't accept it. IMO allowing setting null
is not a good choice.
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.
IMO, if the database doesn't accept the null value, we shouldn't accept it during serialization
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.
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.
#15551 I have removed possibility to set null value. We can achieve the same goal to pass a value of minus one.
src/Sylius/Bundle/CoreBundle/Fixture/Factory/PromotionExampleFactory.php
Outdated
Show resolved
Hide resolved
1cce2ff
to
1c5fc26
Compare
tests/Api/Responses/Expected/admin/promotion/put_promotion_with_null_priority_response.json
Outdated
Show resolved
Hide resolved
} | ||
|
||
return $rules; | ||
return empty($rules) ? [[]] : $rules; |
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 can see that it's been like this before, but is there a particular reason why it's not a simple array?
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.
Ok, it has been working in a way that if I pass an empty array, then this normalizer
returns an empty array within an array, which previously created a promotion with at least one action/rule. For the purpose of using this in Behat tests, where I need to create a promotion without any actions/rules, I've added the option to pass a null value. In this case, it will return an empty array, so no actions/rules are added. If someone passes an empty array, the behavior will remain as it was before.
1c5fc26
to
2aecfb9
Compare
…motionContext class
2aecfb9
to
70299c1
Compare
src/Sylius/Bundle/ApiBundle/OpenApi/Documentation/PromotionDocumentationModifier.php
Show resolved
Hide resolved
<group>admin:promotion:create</group> | ||
<group>admin:promotion:update</group> | ||
<denormalization_context> | ||
<entry name="disable_type_enforcement">true</entry> |
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 question is whether we want to accept a null value if the db doesn't accept it. IMO allowing setting null
is not a good choice.
src/Sylius/Bundle/CoreBundle/Fixture/Factory/PromotionExampleFactory.php
Show resolved
Hide resolved
<group>admin:promotion:create</group> | ||
<group>admin:promotion:update</group> | ||
<denormalization_context> | ||
<entry name="disable_type_enforcement">true</entry> |
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.
IMO, if the database doesn't accept the null value, we shouldn't accept it during serialization
src/Sylius/Bundle/CoreBundle/Fixture/Factory/PromotionExampleFactory.php
Show resolved
Hide resolved
Thanks, Karol! 🥇 |