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

Save credit memos on server during generation #373

Merged
merged 15 commits into from
Jul 4, 2022

Conversation

GSadee
Copy link
Member

@GSadee GSadee commented Jun 29, 2022

Q A
Branch? 1.3
Bug fix? no
New feature? yes
Related tickets fixes #351

@GSadee GSadee added the Feature New feature proposals. label Jun 29, 2022
@GSadee GSadee requested a review from a team as a code owner June 29, 2022 21:40
@GSadee GSadee force-pushed the save-credit-memos-on-server branch 2 times, most recently from a363ad3 to 3c9e777 Compare June 30, 2022 06:02
@GSadee GSadee force-pushed the save-credit-memos-on-server branch from 0f2a1a9 to 5e1260f Compare June 30, 2022 06:33
@GSadee GSadee changed the title [WIP] Save credit memos on server during generation Save credit memos on server during generation Jun 30, 2022
Comment on lines 79 to 91
private function generatePdf(CreditMemoInterface $creditMemo): void
{
if (!$this->hasEnabledPdfFileGenerator) {
return;
}

if (null === $this->creditMemoPdfFileGenerator || null === $this->creditMemoFileManager) {
return;
}

$creditMemoPdf = $this->creditMemoPdfFileGenerator->generate($creditMemo->getId());
$this->creditMemoFileManager->save($creditMemoPdf);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

We're already injecting 3 new arguments into this service, also this method does not return anything and is quite independent. Maybe let's create a separate service for generating and saving pdf credit memos and inject it here? It would result in better encapsulation and having only one new argument injected here 🖖

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 used here the created resolver, as it does what I need, but I have some doubts if this is a proper service, as its name could be misleading 🤔

@GSadee GSadee force-pushed the save-credit-memos-on-server branch 3 times, most recently from 3ab6208 to 53c32ef Compare July 1, 2022 15:39
@GSadee GSadee force-pushed the save-credit-memos-on-server branch from 53c32ef to 2549553 Compare July 1, 2022 16:03
/** @test */
function it_creates_file_in_given_filesystem(): void
{
$creditMemoFileManager = $this->prepareCreditMemoFileManager();
Copy link
Contributor

Choose a reason for hiding this comment

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

We could call this function in setUp method


$this->assertEquals($creditMemoPdf, $file);

$this->clearTemporaryDirectory();
Copy link
Contributor

Choose a reason for hiding this comment

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

And this in tearDown 💃

@Zales0123 Zales0123 merged commit aa777fd into Sylius:1.3 Jul 4, 2022
@Zales0123
Copy link
Contributor

Thanks, Grzegorz! 🥇

@GSadee GSadee deleted the save-credit-memos-on-server branch July 11, 2022 18:27
@GSadee GSadee mentioned this pull request Feb 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature New feature proposals.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] PDFs are not stored permanently, sending breaks with "not found"
4 participants