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

[CreditMemo] Refactor creating CreditMemo to use a factory #295

Merged
merged 2 commits into from
May 25, 2021

Conversation

GSadee
Copy link
Member

@GSadee GSadee commented May 24, 2021

Fixes #278

@GSadee GSadee added the DX Issues and PRs aimed at improving Developer eXperience. label May 24, 2021
@GSadee GSadee requested a review from a team as a code owner May 24, 2021 10:37
spec/Factory/CreditMemoFactorySpec.php Show resolved Hide resolved
Comment on lines +48 to +50
$creditMemo = $this->creditMemoFactory->createNew();

return $creditMemo;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
$creditMemo = $this->creditMemoFactory->createNew();
return $creditMemo;
$return $this->creditMemoFactory->createNew();

Maybe this will work?

Copy link
Member Author

Choose a reason for hiding this comment

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

I need to add a type hint to this variable because of static analysis

@@ -0,0 +1,91 @@
<?php

declare(strict_types=1);
Copy link
Contributor

@arti0090 arti0090 May 25, 2021

Choose a reason for hiding this comment

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

What about license blocks? Here and in interface? We don't use them here? (ps. and in specs)

Copy link
Member Author

@GSadee GSadee May 25, 2021

Choose a reason for hiding this comment

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

We don't have them in almost the entire project, but we probably should 🤔 I've added it at least in these new classes

Copy link
Contributor

Choose a reason for hiding this comment

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

Should be handled by the coding standard tool.

src/Resources/config/services/factory.xml Outdated Show resolved Hide resolved
public function getLineItems(): Collection
{
return $this->lineItems;
}

public function setLineItems(Collection $lineItems): void
Copy link
Contributor

Choose a reason for hiding this comment

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

Could it be replaced by the adder method?

Anyway, we should create an empty collection in the constructor as well - currently, it'll crash while flushing the changes if setLineItems and setTaxItems are not called.

Copy link
Member Author

Choose a reason for hiding this comment

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

I've added creating collections in constructor, but I'm not convince to changing these setters (setTaxItems() and setLineItems()) to adders as these are collections that shouldn't have too many operations

src/Resources/config/services/factory.xml Outdated Show resolved Hide resolved
@@ -0,0 +1,91 @@
<?php

declare(strict_types=1);
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be handled by the coding standard tool.

@pamil pamil merged commit ad02c0f into Sylius:master May 25, 2021
@pamil
Copy link
Contributor

pamil commented May 25, 2021

Thanks, Grzegorz! 🎉

pamil added a commit to Sylius/Sylius that referenced this pull request May 25, 2021
…g a new field (GSadee)

This PR was merged into the 1.9 branch.

Discussion
----------

| Q               | A
| --------------- | -----
| Branch?         | 1.9
| Bug fix?        | no
| New feature?    | no
| BC breaks?      | no
| Deprecations?   | no
| Related tickets | associated with changes from Sylius/RefundPlugin#295
| License         | MIT


Commits
-------

77e4fe4 [Documentation] Customizing CreditMemo entity by adding a new field
@GSadee GSadee deleted the credit-memo-factory branch May 26, 2021 04:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DX Issues and PRs aimed at improving Developer eXperience.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use resource factory to create CreditMemo in CreditMemoGenerator
4 participants