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

fix/DEN-299 optionally allow keys for tax-categories #46

Conversation

cedrix-bestit
Copy link

This fixes the problem that tax-categories are null (which is not allowed) by either using id's or keys (new), if there is no id given. This is necessary for DEN-299.

Lars Neujeffski

@cedrix-bestit cedrix-bestit force-pushed the fix/DEN-299-optionally-key-for-taxcategories branch from 7ccff8b to 644e007 Compare March 5, 2020 16:46
Copy link
Contributor

@b3nl b3nl left a comment

Choose a reason for hiding this comment

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

... And please add the key check to the existing unit test!

* @param mixed $changedValue
* @param ClassMetadataInterface $metadata
* @param array $changedData
* @param array $oldData
* @param mixed $sourceObject
*
* @return AbstractAction[]
* @todo The documentation does not tell of the staged param in the action. what does that mean?
Copy link
Contributor

Choose a reason for hiding this comment

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

Please revert to default style guide.

*/
public function createUpdateActions(
$changedValue,
ClassMetadataInterface $metadata,
array $changedData,
array $oldData,
$sourceObject
): array {
): array
Copy link
Contributor

Choose a reason for hiding this comment

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

What happened here?

$action = new ProductSetTaxCategoryAction();

if ($changedValue) {
$action->setTaxCategory(TaxCategoryReference::ofId($changedValue['id']));
if (isset($changedValue['id']) && $changedValue['id'] !== null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove the double null check.

$action->setTaxCategory(TaxCategoryReference::ofId($changedValue['id']));
} else {
if (isset($changedValue['key']) && $changedValue['key'] !== null) {
$action->setTaxCategory(TaxCategoryReference::ofKey($changedValue['key']));
Copy link
Contributor

Choose a reason for hiding this comment

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

If the reference with keyw work now, then this is fine for me.

@b3nl
Copy link
Contributor

b3nl commented Mar 6, 2020

(and this is no fix, but a feature).

@bestit-el-bardan
Copy link
Contributor

bestit-el-bardan commented Mar 8, 2020

Since I couldn't update the branch to add the tests, I've created a new PR (#48) and am closing this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants